mirror of
https://gitlab.silvrtree.co.uk/martind2000/nci.git
synced 2025-01-25 17:56:17 +00:00
check exit code on close
This commit is contained in:
parent
75734b8d9a
commit
bdce719b4e
@ -31,17 +31,16 @@ Command.prototype.run = function(params, callback) {
|
||||
stdout += data;
|
||||
});
|
||||
cmd.stderr.on('data', function(data) {
|
||||
callback(new Error('Scm outputs to stderr: ' + data));
|
||||
callback(new Error('Spawned command outputs to stderr: ' + data));
|
||||
cmd.kill();
|
||||
});
|
||||
cmd.on('exit', function(code) {
|
||||
if (code !== 0) callback(new Error(
|
||||
'Spawned command exits with non-zero code: ' + code
|
||||
));
|
||||
});
|
||||
// TODO; callback should be called only once (port once from underscore)
|
||||
cmd.on('close', function() {
|
||||
callback(null, stdout);
|
||||
cmd.on('close', function(code) {
|
||||
var err = null;
|
||||
if (code !== 0) err = new Error(
|
||||
'Spawned command exits with non-zero code: ' + code
|
||||
);
|
||||
callback(err, stdout);
|
||||
});
|
||||
return cmd;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user