-
-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use standard JavaScript modules (#67)
Closes #49 Signed-off-by: Jon Koops <[email protected]> Co-authored-by: Mathias Buus <[email protected]>
- Loading branch information
Showing
6 changed files
with
36 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,8 +19,8 @@ npm i [email protected] -g | |
## Usage | ||
|
||
```js | ||
const log = require('why-is-node-running') // should be your first require | ||
const net = require('net') | ||
import why from 'why-is-node-running' // should be your first import | ||
import net from 'node:net' | ||
|
||
function createServer () { | ||
const server = net.createServer() | ||
|
@@ -32,7 +32,7 @@ createServer() | |
createServer() | ||
|
||
setTimeout(function () { | ||
log() // logs out active handles that are keeping node running | ||
why() // logs out active handles that are keeping node running | ||
}, 100) | ||
``` | ||
|
||
|
@@ -89,12 +89,12 @@ To trigger the log: | |
kill -SIGUSR1 31115 | ||
``` | ||
|
||
## Require CLI Option | ||
## Import CLI Option | ||
|
||
You can also use the node `-r` option to include `why-is-node-running`: | ||
You can also use Node's [`--import`](https://nodejs.org/api/cli.html#--importmodule) option to preload `why-is-node-running`: | ||
|
||
```bash | ||
node -r why-is-node-running/include /path/to/some/file.js | ||
node --import why-is-node-running/include /path/to/some/file.js | ||
``` | ||
|
||
The steps are otherwise the same as the above CLI section | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
var why = require('./') | ||
import why from './index.js' | ||
import siginfo from 'siginfo' | ||
|
||
require('siginfo')(why, true) | ||
siginfo(why, true) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters