Skip to content

Commit

Permalink
feat: add support for --spawn
Browse files Browse the repository at this point in the history
Fixes #1245
  • Loading branch information
remy committed Feb 8, 2018
1 parent 846c473 commit 1e2492f
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ nodemon was originally written to restart hanging processes such as web servers,

## Manual restarting

Whilst nodemon is running, if you need to manually restart your application, instead of stopping and restart nodemon, you can simply type `rs` with a carriage return, and nodemon will restart your process.
Whilst nodemon is running, if you need to manually restart your application, instead of stopping and restart nodemon, you can type `rs` with a carriage return, and nodemon will restart your process.

## Config files

Expand Down
1 change: 1 addition & 0 deletions doc/cli/options.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Execution
--cwd <dir> .............. change into <dir> before running the script
-e, --ext ................ extensions to look for, ie. "js,jade,hbs"
-I, --no-stdin ........... nodemon passes stdin directly to child process
--spawn .................. force nodemon to use spawn (over fork) [node only]
-x, --exec app ........... execute script with "app", ie. -x "python -v"
-- <your args> ........... to tell nodemon stop slurping arguments

Expand Down
6 changes: 5 additions & 1 deletion faq.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ This is being added to as common issues occur on the [issues](http://github.com/

This is a working document, and if it makes sense, I'll take pull requests to help make it better.

## nodemon doesn't work with my REPL
# nodemon doesn't work with my REPL

Create an nodemon.json file with the setting:

Expand All @@ -16,6 +16,10 @@ Create an nodemon.json file with the setting:

This will leave the STDIN to your application rather than listening for the `rs` command to restart.

# Strange/failing behaviour starting the (node-based) executable

By default, nodemon will try to fork your node scripts ([background reading](https://github.com/remy/nodemon/issues/1025)), however, there are some edge cases where that won't suit your needs. Most of the time the default configuration should be fine, but if you want to force nodemon to spawn your node process, use the `--spawn` option.

# My script arguments are being taken by nodemon

Use the `--` switch to tell nodemon to ignore all arguments after this point. So to pass `-L` to your script instead of nodemon, use:
Expand Down
3 changes: 3 additions & 0 deletions lib/cli/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,9 @@ function nodemonOption(options, arg, eatNext) {
options.noUpdateNotifier = true;
} else

if (arg === '--spawn') {
options.spawn = true;
} else

if (arg === '--dump') {
options.dump = true;
Expand Down
1 change: 1 addition & 0 deletions lib/monitor/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ function run(options) {
const hasStdio = utils.satisfies('>= 6.4.0 || < 5');

if (
!config.options.spawn &&
firstArg.indexOf('-') === -1 && // don't fork if there's a node arg
firstArg !== 'inspect' && // don't fork it's `inspect` debugger
executable === 'node' && // only fork if node
Expand Down

0 comments on commit 1e2492f

Please sign in to comment.