From 3c352f2f27b151e84537220f3bb4e6fdbb521806 Mon Sep 17 00:00:00 2001 From: Tim Kang Date: Mon, 4 Sep 2017 11:41:35 -0700 Subject: [PATCH] fix: support signal on CLI (#1061) --- lib/cli/parse.js | 4 ++++ test/cli/parse.test.js | 8 +++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/cli/parse.js b/lib/cli/parse.js index 2fb40e2f..2226ac81 100644 --- a/lib/cli/parse.js +++ b/lib/cli/parse.js @@ -194,6 +194,10 @@ function nodemonOption(options, arg, eatNext) { options.colours = false; } else + if (arg === '--signal' || arg === '-s') { + options.signal = eatNext(); + } else + if (arg === '--cwd') { options.cwd = eatNext(); diff --git a/test/cli/parse.test.js b/test/cli/parse.test.js index 26d328de..3f01f667 100644 --- a/test/cli/parse.test.js +++ b/test/cli/parse.test.js @@ -232,7 +232,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 -C -e jade'); + var settings = cli.parse('node nodemon -v -x java -I -V -q -w fixtures -i fixtures -d 5 -L -C -e jade -s SIGHUP'); assert(settings.version, 'version'); assert(settings.verbose, 'verbose'); assert(settings.exec === 'java', 'exec'); @@ -243,11 +243,12 @@ describe('nodemon argument parser', function () { assert(settings.delay === 5000, 'delay 5 seconds'); assert(settings.runOnChangeOnly, 'run on change only'); assert(settings.ext === 'jade', 'extension is jade'); + assert(settings.signal === 'SIGHUP', 'signal is SIGHUP'); }); 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 --on-change-only --ext jade --config my/.nodemon.json'); + 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 --config my/.nodemon.json --signal SIGHUP'); assert(settings.version, 'version'); assert(settings.verbose, 'verbose'); assert(settings.exec === 'java', 'exec'); @@ -259,7 +260,8 @@ describe('nodemon argument parser', function () { assert(settings.delay === 5000, 'delay 5 seconds'); assert(settings.runOnChangeOnly, 'run on change only'); assert(settings.ext === 'jade', 'extension is jade'); - assert(settings.configFile === 'my/.nodemon.json', 'custom config file name is my/.nodemon.json') + assert(settings.configFile === 'my/.nodemon.json', 'custom config file name is my/.nodemon.json'); + assert(settings.signal === 'SIGHUP', 'signal is SIGHUP'); }); });