From 36496681049de2d67ed0092900cbb0ba80b2e6f4 Mon Sep 17 00:00:00 2001 From: Dan Schuman Date: Fri, 23 Oct 2015 14:48:13 -0700 Subject: [PATCH] Handle exit codes --- lib/exec.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/exec.js b/lib/exec.js index b5fdd03..51dc368 100644 --- a/lib/exec.js +++ b/lib/exec.js @@ -15,8 +15,11 @@ module.exports = function exec(script) { }); console.log('to be executed:' + command_line); - var command = child_exec(command_line); - + var command = child_exec(command_line, function (error, stdout, stderr) { + if (error) { + process.exit(error.code || 1); + } + }); command.stdout.on('data', function(data) { process.stdout.write(data); }); @@ -25,6 +28,7 @@ module.exports = function exec(script) { }); command.on('error', function(err) { process.stderr.write(err); + process.exit(err.code || 1); }); -} \ No newline at end of file +}