Skip to content

Commit

Permalink
Merge pull request #167 from basisframework/master
Browse files Browse the repository at this point in the history
fix for issue #166
  • Loading branch information
petruisfan committed Sep 18, 2015
2 parents e739368 + f57b348 commit eb1a827
Showing 1 changed file with 26 additions and 14 deletions.
40 changes: 26 additions & 14 deletions lib/supervisor.js
Expand Up @@ -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;
Expand All @@ -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") {
Expand Down Expand Up @@ -149,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 + "'");
}
Expand All @@ -167,22 +173,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(',');
Expand All @@ -197,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 );
});
Expand Down

0 comments on commit eb1a827

Please sign in to comment.