mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-18 08:56:20 +00:00
refactor(socket) getSpawn
This commit is contained in:
parent
aab1e77b1c
commit
d5ff2471a4
1 changed files with 11 additions and 12 deletions
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue