From e5fd7072c6795d483a4f8fd1026033b63e0b33d7 Mon Sep 17 00:00:00 2001 From: Alex Jeffrey Date: Thu, 17 Sep 2015 08:25:30 +0100 Subject: [PATCH 1/2] Implemented feature for issue #166: option to turn off CLI --- lib/supervisor.js | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/lib/supervisor.js b/lib/supervisor.js index 8cff200..2c72de5 100644 --- a/lib/supervisor.js +++ b/lib/supervisor.js @@ -9,6 +9,7 @@ var debug = true; var verbose = false; var ignoredPaths = {}; var forceWatchFlag = false; +var interactive = true; var log = console.log; exports.run = run; @@ -27,6 +28,8 @@ function run (args) { verbose = true; } else if (arg === "--watch" || arg === "-w") { watch = args.shift(); + } else if (arg == "--non-interactive" || arg === "-t") { + interactive = false; } else if (arg === "--ignore" || arg === "-i") { ignore = args.shift(); } else if (arg === "--save-pid" || arg === "-pid") { @@ -167,22 +170,26 @@ function run (args) { // if we have a watch folder, then watch the folder for changes and restart the prog startChildProcess(); - // - // Read input from stdin - // - var stdin = process.stdin; + // If interaction has not been disabled, start the CLI + if(interactive) { - stdin.setEncoding( 'utf8' ); - stdin.on('readable', function() { - var chunk = process.stdin.read(); // - // Restart process when user inputs rs + // Read input from stdin // - if (chunk !== null && chunk === "rs\n") { -// process.stdout.write('data: ' + chunk); - crash(); - } - }); + var stdin = process.stdin; + + stdin.setEncoding( 'utf8' ); + stdin.on('readable', function() { + var chunk = process.stdin.read(); + // + // Restart process when user inputs rs + // + if (chunk !== null && chunk === "rs\n") { + // process.stdout.write('data: ' + chunk); + crash(); + } + }); + } if (ignore) { var ignoreItems = ignore.split(','); From f57b3480e74df00daef709e02573cd92839e43c2 Mon Sep 17 00:00:00 2001 From: Alex Jeffrey Date: Thu, 17 Sep 2015 08:31:00 +0100 Subject: [PATCH 2/2] updated startup banner output to respect --non-interactive --- lib/supervisor.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/supervisor.js b/lib/supervisor.js index 2c72de5..0969531 100644 --- a/lib/supervisor.js +++ b/lib/supervisor.js @@ -152,6 +152,9 @@ function run (args) { log("Running node-supervisor with"); log(" program '" + program.join(" ") + "'"); log(" --watch '" + watch + "'"); + if (!interactive) { + log(" --non-interactive"); + } if (ignore) { log(" --ignore '" + ignore + "'"); } @@ -204,7 +207,9 @@ function run (args) { watchItems.forEach(function (watchItem) { watchItem = path.resolve(watchItem); log("Watching directory '" + watchItem + "' for changes."); - log("Press rs for restarting the process."); + if(interactive) { + log("Press rs for restarting the process."); + } findAllWatchFiles(watchItem, function(f) { watchGivenFile( f, poll_interval ); });