Skip to content

Commit e95f172

Browse files
authored
Merge pull request #1 from bluebrat/runOnChangeOnly-option
Implement runOnChangeOnly option
2 parents 559606e + f56cb5b commit e95f172

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,11 @@ the values should be a glob pattern or array of glob patterns to watch.
6060
Also it is now possible to obtain a second parameter to define the script which should be run for watching and not watch all possible scripts at once.
6161

6262
If you need to watch files with extensions other than those that `nodemon` watches [by default](https://github.com/remy/nodemon#specifying-extension-watch-list) (`.js`, `.coffee`, `.litcoffee`), you can set the value to an object with `patterns` and `extensions` keys. You can also add an `ignore` key (a list or a string) to ignore specific files. Finally, you can add a `quiet` flag to hide the script name in any output on stdout or stderr, or you can use the `inherit` flag to preserve the original's process stdout or stderr. You can enable `nodemon` [legacy watch](https://github.com/remy/nodemon#application-isnt-restarting) and specify the restart [delay](https://github.com/remy/nodemon#delaying-restarting) in milliseconds with the corresponding flags.
63+
6364
> The `quiet` flag was changed from a `string` to a `boolean` in `0.1.5`. Backwards compatability will be kept for two patch versions.
6465
66+
Use `runOnChangeOnly` to set the nodemon option [--on-change-only](https://github.com/remy/nodemon/blob/master/doc/cli/options.txt "--on-change-only"). Setting this to `true` tells nodemon to execute script on change only, not startup.
67+
6568
```javascript
6669
{
6770
"watch": {
@@ -71,7 +74,8 @@ If you need to watch files with extensions other than those that `nodemon` watch
7174
"ignore": "src/vendor/external.min.js",
7275
"quiet": true,
7376
"legacyWatch": true,
74-
"delay": 2500
77+
"delay": 2500,
78+
"runOnChangeOnly": false
7579
}
7680
},
7781
"scripts": {

watch-package.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ function startScript(script, pkg, processes) {
9494
var inherit = null
9595
var legacyWatch = null
9696
var delay = null
97+
var runOnChangeOnly = null
9798

9899
if (typeof pkg.watch[script] === 'object' && !Array.isArray(pkg.watch[script])) {
99100
patterns = pkg.watch[script].patterns
@@ -103,6 +104,7 @@ function startScript(script, pkg, processes) {
103104
inherit = pkg.watch[script].inherit
104105
legacyWatch = pkg.watch[script].legacyWatch
105106
delay = pkg.watch[script].delay
107+
runOnChangeOnly = pkg.watch[script].runOnChangeOnly
106108
} else {
107109
patterns = pkg.watch[script]
108110
}
@@ -126,6 +128,7 @@ function startScript(script, pkg, processes) {
126128
if (ignores) { args = args.concat(ignores) }
127129
if (legacyWatch) { args = args.concat(['--legacy-watch']) }
128130
if (delay) { args = args.concat(['--delay', delay + 'ms']) }
131+
if (runOnChangeOnly) { args = args.concat(['--on-change-only']) }
129132
args = args.concat(['--exec', exec])
130133
var proc = processes[script] = spawn(nodemon, args, {
131134
env: process.env,

0 commit comments

Comments
 (0)