Skip to content

Commit

Permalink
delegate taking down the process to the bin file not the cli lib
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Mar 28, 2015
1 parent 8c680e7 commit f2fad27
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
5 changes: 5 additions & 0 deletions bin.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,9 @@ var argv = require('yargs')
.help('h')
.argv;

process.on('uncaughtException', function (err) {
console.error(err.message);
process.exit(1);
});

require('./lib/cli').run(argv);
9 changes: 3 additions & 6 deletions lib/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ var async = require('async');

var handleError = function (err) {
if (err) {
console.error(err.message);
process.exit(1);
throw err;
}
};

var dryRunHandler = function (err, cmds) {
handleError(err);
console.log(JSON.stringify(cmds, null, " "));
};

var executeHandler = function (err, cmds) {
handleError(err);
// create one cp function cmd that execs and cbs to next in async series
Expand All @@ -27,10 +27,7 @@ var executeHandler = function (err, cmds) {
});

// exec commands synchronously
async.series(execs, function (err) {
handleError(err);
process.exit(0);
});
async.series(execs, handleError);
};


Expand Down

0 comments on commit f2fad27

Please sign in to comment.