Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use strict';
var spawn = require('child_process').spawn;

var sh, shFlag, children, args, wait, cmds, verbose, i ,len;
var sh, shFlag, children, args, wait, first, cmds, verbose, i ,len;
// parsing argv
cmds = [];
args = process.argv.slice(2);
Expand All @@ -14,15 +14,20 @@ for (i = 0, len = args.length; i < len; i++) {
case '--wait':
wait = true;
break;
case '-f':
case '--first':
first = true;
break;
case '-v':
case '--verbose':
verbose = true;
break;
case '-h':
case '--help':
console.log('-h, --help output usage information');
console.log('-v, --verbose verbose logging')
console.log('-w, --wait will not close sibling processes on error')
console.log('-v, --verbose verbose logging');
console.log('-w, --wait will not close sibling processes on error');
console.log('-f, --first close all sibling processes after first exits (succes/error)');
process.exit();
break;
}
Expand All @@ -31,6 +36,11 @@ for (i = 0, len = args.length; i < len; i++) {
}
}

if (wait && first) {
console.error('--wait and --first cannot be used together');
process.exit(1);
}

// called on close of a child process
function childClose (code) {
var i, len;
Expand All @@ -42,7 +52,7 @@ function childClose (code) {
console.log('`' + this.cmd + '` ended successfully');
}
}
if (code > 0 && !wait) close(code);
if (first || code > 0 && !wait) close(code);
status();
}

Expand Down