diff --git a/doc/cli/help.txt b/doc/cli/help.txt index 19600ea..e358c4e 100644 --- a/doc/cli/help.txt +++ b/doc/cli/help.txt @@ -10,7 +10,7 @@ -q, --quiet .............. minimise nodemon messages to start/stop only. -V, --verbose ............ show detail on what is causing restarts. -I, --no-stdin ........... don't try to read from stdin. - -S, --no-startup ......... disable running script on startup. + -C, --on-change-only ..... execute script on change only, not startup -d, --delay n ............ debounce restart for "n" seconds. -L, --legacy-watch ....... Forces node to use the most compatible version for watching file changes. diff --git a/lib/cli/parse.js b/lib/cli/parse.js index 0743688..c6b699d 100644 --- a/lib/cli/parse.js +++ b/lib/cli/parse.js @@ -191,8 +191,8 @@ function nodemonOption(options, arg, eatNext) { options.stdin = false; } - else if (arg === '--no-startup' || arg === '-S') { - options.runOnStartup = false; + else if (arg === '--on-change-only' || arg === '-C') { + options.runOnChangeOnly = true; } else if (arg === '--ext' || arg === '-e') { diff --git a/lib/config/defaults.js b/lib/config/defaults.js index 5a91ce4..95d4e91 100644 --- a/lib/config/defaults.js +++ b/lib/config/defaults.js @@ -11,7 +11,7 @@ module.exports = { ignore: ['.git', 'node_modules', 'bower_components', '.sass-cache'], watch: ['*.*'], stdin: true, - runOnStartup: true, + runOnChangeOnly: false, verbose: false, // 'stdout' refers to the default behaviour of a required nodemon's child, // but also includes stderr. If this is false, data is still dispatched via diff --git a/lib/monitor/run.js b/lib/monitor/run.js index 34ae9ed..ad5dc52 100644 --- a/lib/monitor/run.js +++ b/lib/monitor/run.js @@ -24,7 +24,7 @@ exec('ps', function(error) { function run(options) { var cmd = config.command.raw; - var runCmd = config.lastStarted !== 0 || options.runOnStartup; + var runCmd = !options.runOnChangeOnly || config.lastStarted !== 0; if (runCmd) { utils.log.status('starting `' + config.command.string + '`'); } diff --git a/test/cli/parse.test.js b/test/cli/parse.test.js index 02a3514..58e1cf2 100644 --- a/test/cli/parse.test.js +++ b/test/cli/parse.test.js @@ -237,7 +237,7 @@ describe('nodemon argument parser', function () { }); it('should support short versions of flags', function () { - var settings = cli.parse('node nodemon -v -x java -I -V -q -w fixtures -i fixtures -d 5 -L -S -e jade'); + var settings = cli.parse('node nodemon -v -x java -I -V -q -w fixtures -i fixtures -d 5 -L -C -e jade'); assert(settings.version, 'version'); assert(settings.verbose, 'verbose'); assert(settings.exec === 'java', 'exec'); @@ -247,13 +247,13 @@ describe('nodemon argument parser', function () { assert(settings.ignore[0] === 'fixtures', 'ignore'); assert(settings.delay === 5000, 'delay 5 seconds'); assert(settings.legacyWatch, 'legacy watch method'); - assert(settings.runOnStartup === false, 'run on startup'); + assert(settings.runOnChangeOnly, 'run on change only'); assert(settings.ext === 'jade', 'extension is jade'); }); it('should support long versions of flags', function () { - var settings = cli.parse('node nodemon --version --exec java --verbose --quiet --watch fixtures --ignore fixtures --no-stdin --delay 5 --legacy-watch --exitcrash --no-startup --ext jade'); + var settings = cli.parse('node nodemon --version --exec java --verbose --quiet --watch fixtures --ignore fixtures --no-stdin --delay 5 --legacy-watch --exitcrash --on-change-only --ext jade'); assert(settings.version, 'version'); assert(settings.verbose, 'verbose'); assert(settings.exec === 'java', 'exec'); @@ -264,7 +264,7 @@ describe('nodemon argument parser', function () { assert(settings.ignore[0] === 'fixtures', 'ignore'); assert(settings.delay === 5000, 'delay 5 seconds'); assert(settings.legacyWatch, 'legacy watch method'); - assert(settings.runOnStartup === false, 'run on startup'); + assert(settings.runOnChangeOnly, 'run on change only'); assert(settings.ext === 'jade', 'extension is jade'); }); }); diff --git a/test/monitor/run.test.js b/test/monitor/run.test.js index 9864a63..c5fb954 100644 --- a/test/monitor/run.test.js +++ b/test/monitor/run.test.js @@ -106,12 +106,12 @@ describe('when nodemon runs (2)', function () { }); }); - it('should not run command if runOnStartup is false', function(done) { + it('should not run command on startup if runOnChangeOnly is true', function(done) { fs.writeFileSync(tmp, 'console.log("testing 1 2 3")'); nodemon({ script: tmp, - runOnStartup: false, + runOnChangeOnly: true, stdout: false }).on('stdout', function() { assert(false, 'there should not be any stdout');