diff --git a/lib/server/console.js b/lib/server/console.js index 31caff48..031fbca3 100644 --- a/lib/server/console.js +++ b/lib/server/console.js @@ -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) {