mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 10:45:47 +00:00
feature(spawnify) callback: json -> error, json
This commit is contained in:
parent
18db1ef37c
commit
88a23f4d5a
2 changed files with 9 additions and 11 deletions
|
|
@ -21,7 +21,7 @@
|
|||
|
||||
module.exports = function() {
|
||||
socket.on('connection', function(clientSocket) {
|
||||
onConnection(clientSocket, function(json) {
|
||||
onConnection(clientSocket, function(error, json) {
|
||||
socket.emit(CHANNEL, json, clientSocket);
|
||||
});
|
||||
});
|
||||
|
|
@ -37,7 +37,7 @@
|
|||
if (!Clients[ConNum]) {
|
||||
msg = log(ConNum, 'console connected');
|
||||
|
||||
callback({
|
||||
callback(null, {
|
||||
stdout : addNewLine(msg),
|
||||
path : CWD
|
||||
});
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
} else {
|
||||
msg = log(ConNum, ' in use. Reconnecting...\n');
|
||||
|
||||
callback({
|
||||
callback(null, {
|
||||
stdout: msg
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -58,12 +58,12 @@
|
|||
onCD(command, dir, function(error, json) {
|
||||
var path;
|
||||
|
||||
if (json.path) {
|
||||
if (!error && json.path) {
|
||||
path = json.path;
|
||||
options.cwd = path;
|
||||
}
|
||||
|
||||
callback(json);
|
||||
callback(error, json);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -108,7 +108,7 @@
|
|||
stderr : errorStr
|
||||
};
|
||||
|
||||
callback(json, error, stderr);
|
||||
callback(error, json);
|
||||
}
|
||||
|
||||
function setSpawn(сommand, options, callback) {
|
||||
|
|
@ -119,8 +119,6 @@
|
|||
var errorStr = '';
|
||||
|
||||
isSended = true;
|
||||
callback(error, stdout, stderr);
|
||||
|
||||
if (error)
|
||||
errorStr = error.message;
|
||||
else if (stderr)
|
||||
|
|
@ -128,7 +126,7 @@
|
|||
|
||||
errorStr = addNewLine(errorStr);
|
||||
|
||||
callback({
|
||||
callback(error, {
|
||||
stderr: errorStr,
|
||||
stdout: stdout
|
||||
});
|
||||
|
|
@ -148,7 +146,7 @@
|
|||
});
|
||||
|
||||
if (error) {
|
||||
callback(error);
|
||||
func(error);
|
||||
} else {
|
||||
cmd.stderr.setEncoding('utf8');
|
||||
cmd.stdout.setEncoding('utf8');
|
||||
|
|
@ -200,7 +198,7 @@
|
|||
path = '';
|
||||
}
|
||||
|
||||
callback(error || stderr, {
|
||||
callback(error, {
|
||||
stderr : addNewLine(errorStr),
|
||||
stdout : stdout,
|
||||
path : path
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue