mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-19 01:17:18 +00:00
refactor(console) setSpawn
This commit is contained in:
parent
2ea3cffad6
commit
10103817a1
1 changed files with 12 additions and 11 deletions
|
|
@ -180,15 +180,19 @@
|
|||
isSended = false,
|
||||
args = сommand.split(' '),
|
||||
send = function(error, data) {
|
||||
var exec = {
|
||||
stderr: error,
|
||||
stdout: data
|
||||
};
|
||||
if (!isSended)
|
||||
isSended = true;
|
||||
|
||||
Util.exec(callback, exec);
|
||||
callback({
|
||||
stderr: error,
|
||||
stdout: data
|
||||
});
|
||||
},
|
||||
sendError = function(error) {
|
||||
send(error, null);
|
||||
if (!isSended) {
|
||||
isSended = true;
|
||||
send(error, null);
|
||||
}
|
||||
};
|
||||
|
||||
сommand = args.shift();
|
||||
|
|
@ -205,12 +209,10 @@
|
|||
|
||||
cmd.stdout.on('data', function(data) {
|
||||
send(null, data);
|
||||
isSended = true;
|
||||
});
|
||||
|
||||
cmd.stderr.on('data', function(data) {
|
||||
sendError(data);
|
||||
isSended = true;
|
||||
cmd.stderr.on('data', function(error) {
|
||||
sendError(error);
|
||||
});
|
||||
|
||||
cmd.on('error', function(error) {
|
||||
|
|
@ -218,7 +220,6 @@
|
|||
|
||||
Util.log(error);
|
||||
sendError(errorStr);
|
||||
isSended = true;
|
||||
});
|
||||
|
||||
cmd.on('close', function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue