Skip to content

Commit 5e88b04

Browse files
authoredFeb 15, 2018
feat: add support for --spawn (#1249)
* docs: add sponsors [skip ci] * feat: add support for `--spawn` Fixes #1245 * docs: remove "simply"
1 parent 0e08ee2 commit 5e88b04

File tree

9 files changed

+19
-10
lines changed

9 files changed

+19
-10
lines changed
 

‎README.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ For use during development of a node.js based application.
66

77
nodemon will watch the files in the directory in which nodemon was started, and if any files change, nodemon will automatically restart your node application.
88

9-
nodemon does **not** require *any* changes to your code or method of development. nodemon simply wraps your node application and keeps an eye on any files that have changed. Remember that nodemon is a replacement wrapper for `node`, think of it as replacing the word "node" on the command line when you run your script.
9+
nodemon does **not** require *any* changes to your code or method of development. nodemon wraps your node application and keeps an eye on any files that have changed. Remember that nodemon is a replacement wrapper for `node`, think of it as replacing the word "node" on the command line when you run your script.
1010

1111
[![NPM version](https://badge.fury.io/js/nodemon.svg)](https://npmjs.org/package/nodemon)
1212
[![Travis Status](https://travis-ci.org/remy/nodemon.svg?branch=master)](https://travis-ci.org/remy/nodemon) [![Backers on Open Collective](https://opencollective.com/nodemon/backers/badge.svg)](#backers) [![Sponsors on Open Collective](https://opencollective.com/nodemon/sponsors/badge.svg)](#sponsors)
@@ -71,7 +71,7 @@ nodemon was originally written to restart hanging processes such as web servers,
7171

7272
## Manual restarting
7373

74-
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.
74+
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.
7575

7676
## Config files
7777

@@ -96,14 +96,14 @@ A config file can take any of the command line arguments as JSON key values, for
9696
}
9797
```
9898

99-
The above `nodemon.json` file might be my global config so that I have support for ruby files and processing files, and I can simply run `nodemon demo.pde` and nodemon will automatically know how to run the script even though out of the box support for processing scripts.
99+
The above `nodemon.json` file might be my global config so that I have support for ruby files and processing files, and I can run `nodemon demo.pde` and nodemon will automatically know how to run the script even though out of the box support for processing scripts.
100100

101101
A further example of options can be seen in [sample-nodemon.md](https://github.com/remy/nodemon/blob/master/doc/sample-nodemon.md)
102102

103103
### package.json
104104

105105
If you want to keep all your package configurations in one place, nodemon supports using `package.json` for configuration.
106-
Simply specify the config in the same format as you would for a config file but under `nodemonConfig` in the `package.json` file, for example, take the following `package.json`:
106+
Specify the config in the same format as you would for a config file but under `nodemonConfig` in the `package.json` file, for example, take the following `package.json`:
107107

108108
```json
109109
{
@@ -267,7 +267,7 @@ Note that the `process.kill` is *only* called once your shutdown jobs are comple
267267

268268
## Triggering events when nodemon state changes
269269

270-
If you want growl like notifications when nodemon restarts or to trigger an action when an event happens, then you can either `require` nodemon or simply add event actions to your `nodemon.json` file.
270+
If you want growl like notifications when nodemon restarts or to trigger an action when an event happens, then you can either `require` nodemon or add event actions to your `nodemon.json` file.
271271

272272
For example, to trigger a notification on a Mac when nodemon restarts, `nodemon.json` looks like this:
273273

‎doc/cli/options.txt

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Execution
1414
--cwd <dir> .............. change into <dir> before running the script
1515
-e, --ext ................ extensions to look for, ie. "js,jade,hbs"
1616
-I, --no-stdin ........... nodemon passes stdin directly to child process
17+
--spawn .................. force nodemon to use spawn (over fork) [node only]
1718
-x, --exec app ........... execute script with "app", ie. -x "python -v"
1819
-- <your args> ........... to tell nodemon stop slurping arguments
1920

‎doc/requireable.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The `nodemon` object also has a few methods and properties. Some are exposed to
4040

4141
### Event handling
4242

43-
This is simply the event emitter bus that exists inside nodemon exposed at the top level module (ie. it's the `events` api):
43+
This is the event emitter bus that exists inside nodemon exposed at the top level module (ie. it's the `events` api):
4444

4545
- `nodemon.on(event, fn)`
4646
- `nodemon.addListener(event, fn)`

‎faq.md

+6-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ This is being added to as common issues occur on the [issues](http://github.com/
44

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

7-
## nodemon doesn't work with my REPL
7+
# nodemon doesn't work with my REPL
88

99
Create an nodemon.json file with the setting:
1010

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

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

19+
# Strange/failing behaviour starting the (node-based) executable
20+
21+
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.
22+
1923
# My script arguments are being taken by nodemon
2024

2125
Use the `--` switch to tell nodemon to ignore all arguments after this point. So to pass `-L` to your script instead of nodemon, use:
@@ -142,7 +146,7 @@ forever start --uid foo --killSignal=SIGTERM -c 'nodemon --exitcrash' server.js
142146

143147
To test this, you can kill the server.js process and forever will restart it. If you `touch server.js` nodemon will restart it.
144148

145-
To stop the process monitored by forever and nodemon, simply call the following, using the `uid` we assigned above (`foo`):
149+
To stop the process monitored by forever and nodemon, call the following, using the `uid` we assigned above (`foo`):
146150

147151
```bash
148152
forever stop foo

‎lib/cli/parse.js

+3
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ function nodemonOption(options, arg, eatNext) {
117117
options.noUpdateNotifier = true;
118118
} else
119119

120+
if (arg === '--spawn') {
121+
options.spawn = true;
122+
} else
120123

121124
if (arg === '--dump') {
122125
options.dump = true;

‎lib/config/load.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ function load(settings, options, config, callback) {
109109
}
110110

111111
/**
112-
* Loads the old style nodemonignore files which are simply a list of patterns
112+
* Loads the old style nodemonignore files which is a list of patterns
113113
* in a file to ignore
114114
*
115115
* @param {Object} options nodemon user options
@@ -210,7 +210,7 @@ function loadFile(options, config, dir, ready) {
210210

211211
function loadPackageJSON(config, ready) {
212212
if (!ready) {
213-
ready = () => {};
213+
ready = () => { };
214214
}
215215

216216
const dir = process.cwd();

‎lib/monitor/run.js

+1
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ function run(options) {
6666
const hasStdio = utils.satisfies('>= 6.4.0 || < 5');
6767

6868
if (
69+
!config.options.spawn &&
6970
firstArg.indexOf('-') === -1 && // don't fork if there's a node arg
7071
firstArg !== 'inspect' && // don't fork it's `inspect` debugger
7172
executable === 'node' && // only fork if node

‎website/nodemon.png

16 KB
Loading

‎website/sparkpost.png

21.8 KB
Loading

0 commit comments

Comments
 (0)