Skip to content

Commit

Permalink
Merge pull request #29 from andrenarchy/master
Browse files Browse the repository at this point in the history
introduce --first option
  • Loading branch information
paulpflug committed Jul 29, 2015
2 parents 30623e0 + fcb6a74 commit 5177e24
Showing 1 changed file with 14 additions and 4 deletions.
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

0 comments on commit 5177e24

Please sign in to comment.