mirror of
https://github.com/SrIzan10/nodemon.git
synced 2026-05-01 10:55:09 +00:00
chore: Merge branch 'master'
* 'master' of github.com:remy/nodemon: docs: typo on string #24 & #246 (#1374) docs: more docs for nodemon as child process (#1362) Update faq.md Note about procps on Docker fix: in watch, use fully filtered ignore rules chore: update stalebot
This commit is contained in:
2
.github/stale.yml
vendored
2
.github/stale.yml
vendored
@@ -7,7 +7,7 @@ exemptLabels:
|
||||
- pinned
|
||||
- security
|
||||
# Label to use when marking an issue as stale
|
||||
staleLabel: wontfix
|
||||
staleLabel: stale
|
||||
# Comment to post when marking an issue as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This issue has been automatically marked as idle and stale because it hasn't
|
||||
|
||||
14
README.md
14
README.md
@@ -21,7 +21,7 @@ npm install -g nodemon
|
||||
|
||||
And nodemon will be installed globally to your system path.
|
||||
|
||||
You can also install nodemon as a developement dependency:
|
||||
You can also install nodemon as a development dependency:
|
||||
|
||||
```bash
|
||||
npm install --save-dev nodemon
|
||||
@@ -125,9 +125,13 @@ Note that if you specify a `--config` file or provide a local `nodemon.json` any
|
||||
|
||||
Please see [doc/requireable.md](doc/requireable.md)
|
||||
|
||||
## Using nodemon as child process
|
||||
|
||||
Please see [doc/events.md](doc/events.md#Using_nodemon_as_child_process)
|
||||
|
||||
## Running non-node scripts
|
||||
|
||||
nodemon can also be used to execute and monitor other programs. nodemon will read the file extension of the script being run and monitor that extension instead of .js if there's no `nodemon.json`:
|
||||
nodemon can also be used to execute and monitor other programs. nodemon will read the file extension of the script being run and monitor that extension instead of `.js` if there's no `nodemon.json`:
|
||||
|
||||
```bash
|
||||
nodemon --exec "python -v" ./app.py
|
||||
@@ -139,7 +143,7 @@ Now nodemon will run `app.py` with python in verbose mode (note that if you're n
|
||||
|
||||
Using the `nodemon.json` config file, you can define your own default executables using the `execMap` property. This is particularly useful if you're working with a language that isn't supported by default by nodemon.
|
||||
|
||||
To add support for nodemon to know about the .pl extension (for Perl), the nodemon.json file would add:
|
||||
To add support for nodemon to know about the `.pl` extension (for Perl), the `nodemon.json` file would add:
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -177,7 +181,7 @@ By default, nodemon looks for files with the `.js`, `.mjs`, `.coffee`, `.litcoff
|
||||
nodemon -e js,jade
|
||||
```
|
||||
|
||||
Now nodemon will restart on any changes to files in the directory (or subdirectories) with the extensions .js, .jade.
|
||||
Now nodemon will restart on any changes to files in the directory (or subdirectories) with the extensions `.js`, `.jade`.
|
||||
|
||||
## Ignoring files
|
||||
|
||||
@@ -239,7 +243,7 @@ nodemon --delay 2500ms server.js
|
||||
|
||||
The delay figure is number of seconds (or milliseconds, if specified) to delay before restarting. So nodemon will only restart your app the given number of seconds after the *last* file change.
|
||||
|
||||
If you are setting this value in `nodemon.json`, the value will always be interpretted in milliseconds. E.g., the following are equivalent:
|
||||
If you are setting this value in `nodemon.json`, the value will always be interpreted in milliseconds. E.g., the following are equivalent:
|
||||
|
||||
```bash
|
||||
nodemon --delay 2.5
|
||||
|
||||
@@ -47,11 +47,29 @@ nodemon.emit('restart');
|
||||
nodemon.emit('quit');
|
||||
```
|
||||
|
||||
## Using nodemon as child process
|
||||
|
||||
If nodemon is a spawned process, then the child (nodemon) will emit message
|
||||
events whereby the event argument contains the event type, and instead of
|
||||
emitting events, you `send` the command:
|
||||
|
||||
```js
|
||||
// using `spawn` as example, can use other functions like `fork`, etc
|
||||
// https://nodejs.org/api/child_process.html
|
||||
const { spawn } = require('child_process');
|
||||
|
||||
function spawnNodemon() {
|
||||
const cp = spawn('nodemon', ['path/to/file.js', '--watch', 'path/to/watch'], {
|
||||
// the important part is the 4th option 'ipc'
|
||||
// this way `process.send` will be available in the child process (nodemon)
|
||||
// so it can communicate back with parent process (through `.on()`, `.send()`)
|
||||
// https://nodejs.org/api/child_process.html#child_process_options_stdio
|
||||
stdio: ['pipe', 'pipe', 'pipe', 'ipc'],
|
||||
});
|
||||
|
||||
return cp;
|
||||
}
|
||||
|
||||
var app = spawnNodemon();
|
||||
|
||||
app.on('message', function (event) {
|
||||
|
||||
13
faq.md
13
faq.md
@@ -260,3 +260,16 @@ sudo npm i -g npm
|
||||
```
|
||||
|
||||
Otherwise see [issue #1124](https://github.com/remy/nodemon/issues/1124) for further suggestions.
|
||||
|
||||
## No automatic restart when using Docker volumes [issue #419](https://github.com/remy/nodemon/issues/419#issuecomment-391244911)
|
||||
|
||||
Some Node.js Docker images do not seem to have the full suite of filtesystem process utilities that allow `nodemon` to restart automatically when the code in a mounted volume changes. To handle this, and enable automatic restarts without using legacy mode, you can install the [procps](http://procps.sourceforge.net) package.
|
||||
|
||||
Here's an example snippet of a Dockerfile:
|
||||
|
||||
```
|
||||
FROM node:8.9.4-wheezy
|
||||
RUN apt-get update && apt-get install -y procps
|
||||
```
|
||||
|
||||
|
||||
|
||||
@@ -154,6 +154,9 @@ function match(files, monitor, ext) {
|
||||
var prefix = s.slice(0, 1);
|
||||
|
||||
if (prefix === '!') {
|
||||
if (s.indexOf('!' + cwd) === 0) {
|
||||
return s;
|
||||
}
|
||||
return '!**' + (prefix !== path.sep ? path.sep : '') + s.slice(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,12 @@ function watch() {
|
||||
|
||||
const promise = new Promise(function (resolve) {
|
||||
const dotFilePattern = /[/\\]\./;
|
||||
var ignored = Array.from(rootIgnored);
|
||||
var ignored = match.rulesToMonitor(
|
||||
[], // not needed
|
||||
Array.from(rootIgnored),
|
||||
config
|
||||
).map(pattern => pattern.slice(1));
|
||||
|
||||
const addDotFile = dirs.filter(dir => dir.match(dotFilePattern));
|
||||
|
||||
// don't ignore dotfiles if explicitly watched.
|
||||
|
||||
Reference in New Issue
Block a user