refactor(console) getExec

This commit is contained in:
coderaiser 2014-05-20 07:24:33 -04:00
parent ce53fbc848
commit 1c30ad888a

View file

@ -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) {