From b1aea5f7adf75cdb7c5b840abefe620ac78f0b21 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 25 Jul 2014 04:14:29 -0400 Subject: [PATCH] fix(console) cd: if error in one of shell commands change directory --- lib/server/console.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/lib/server/console.js b/lib/server/console.js index ee951194..231312da 100644 --- a/lib/server/console.js +++ b/lib/server/console.js @@ -130,9 +130,9 @@ ret = true; onCD(command, dir, function(error, json) { - var path = ''; + var path; - if (!error) { + if (json.path) { path = json.path; ClientDirs[connNum] = path; } @@ -291,17 +291,20 @@ } exec(command, {cwd : paramDir}, function (error, stdout, stderr) { - var errorStr = ''; + var path = paramDir, + errorStr = ''; - if (stderr) + if (stderr) { errorStr = stderr; - else if (error) + } else if (error) { errorStr = error.message; + path = ''; + } callback(error || stderr, { stderr : addNewLine(errorStr), stdout : stdout, - path : paramDir + path : path }); }); }