refactor(socket) getSpawn

This commit is contained in:
coderaiser 2014-01-24 09:16:46 -05:00
parent aab1e77b1c
commit d5ff2471a4

View file

@ -247,22 +247,21 @@
});
if (cmd) {
send = function(data, isError) {
var lExec = {},
msg = data.toString();
if (isError)
lExec.stderr = msg;
else
lExec.stdout = msg;
send = function(error, data) {
var exec = {
stderr: error + '',
stdout: data + ''
};
Util.exec(callback, lExec);
Util.exec(callback, exec);
};
cmd.stdout.on('data', send);
cmd.stdout.on('data', function(data) {
send(null, data);
});
cmd.stderr.on('data', function(data) {
send(data, true);
cmd.stderr.on('data', function(error) {
send(error);
});
cmd.on('error', Util.retFalse);