mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-07-21 02:29:23 +00:00
refactor(console) getExec
This commit is contained in:
parent
ce53fbc848
commit
1c30ad888a
1 changed files with 13 additions and 16 deletions
|
|
@ -149,7 +149,7 @@
|
|||
}
|
||||
|
||||
if (!ClientFuncs[connNum])
|
||||
ClientFuncs[connNum] = getExec(function(json, error, stderr) {
|
||||
ClientFuncs[connNum] = Util.bind(getExec, function(json, error, stderr) {
|
||||
log(connNum, error, 'error');
|
||||
log(connNum, stderr, 'stderror');
|
||||
|
||||
|
|
@ -182,27 +182,24 @@
|
|||
* function send result of command to client
|
||||
* @param callback
|
||||
*/
|
||||
function getExec(callback) {
|
||||
return function(pError, pStdout, pStderr) {
|
||||
var lErrorStr, lExec,
|
||||
lError = pStderr || pError;
|
||||
function getExec(callback, error, stdout, stderr) {
|
||||
var json,
|
||||
errorStr = stderr || error,
|
||||
isStr = Util.isString(errorStr);
|
||||
|
||||
if (lError) {
|
||||
if (Util.isString(lError))
|
||||
lErrorStr = lError;
|
||||
else
|
||||
lErrorStr = lError.toString();
|
||||
if (errorStr) {
|
||||
if (!isStr)
|
||||
errorStr = errorStr.toString();
|
||||
|
||||
lErrorStr = CloudFunc.addNewLine(lErrorStr);
|
||||
errorStr = CloudFunc.addNewLine(errorStr);
|
||||
}
|
||||
|
||||
lExec = {
|
||||
stdout : pStdout,
|
||||
stderr : lErrorStr || lError
|
||||
json = {
|
||||
stdout : stdout,
|
||||
stderr : errorStr
|
||||
};
|
||||
|
||||
Util.exec(callback, lExec, pError, pStderr);
|
||||
};
|
||||
Util.exec(callback, json, error, stderr);
|
||||
}
|
||||
|
||||
function getSpawn(сommand, options, callback) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue