diff --git a/libs/commands.js b/libs/commands.js index 6c69d35..c329bc6 100644 --- a/libs/commands.js +++ b/libs/commands.js @@ -12,13 +12,13 @@ function execute(cmd, args) { spawned.stderr.on('data', function (data) { logger.error(data); }); - spawned.on('close', function (code) { + spawned.on('error', function (err) { + reject('command \'' + cmd + '\' with args \'' + args + '\' encountered an error after ' + util.timeDiff(spawned.timestamp) + 'ms >>> ' + err); + }); + spawned.on('exit', function (code) { logger.debug('command \'' + cmd + '\' with args \'' + args + '\' finished with exit code ' + code + ' after ' + util.timeDiff(spawned.timestamp) + 'ms'); resolve(); }); - spawned.on('error', function (err) { - return reject('command \'' + cmd + '\' with args \'' + args + '\' encountered an error after ' + util.timeDiff(spawned.timestamp) + 'ms >>> ' + err); - }); }); }