fix(console) setSpawn: always send result

This commit is contained in:
coderaiser 2014-07-01 10:07:50 -04:00
parent 314fcca806
commit e97f5e94eb

View file

@ -177,6 +177,7 @@
function setSpawn(сommand, options, callback) {
var cmd, error,
isSended = false,
args = сommand.split(' '),
send = function(error, data) {
var exec = {
@ -204,19 +205,27 @@
cmd.stdout.on('data', function(data) {
send(null, data);
isSended = true;
});
cmd.stderr.on('data', sendError);
cmd.stderr.on('data', function(data) {
sendError(data);
isSended = true;
});
cmd.on('error', function(error) {
var errorStr = addNewLine(error + '');
Util.log(error);
sendError(errorStr);
isSended = true;
});
cmd.on('close', function () {
cmd = null;
if (!isSended)
send(null, null);
});
}
}