diff --git a/src/common.js b/src/common.js index dbca994..d5793c6 100644 --- a/src/common.js +++ b/src/common.js @@ -64,16 +64,15 @@ function error(msg, _code, _continue) { if(config.fatal) throw new Error(log_entry); + if (msg.length > 0) + log(log_entry); + if(!_continue) { - // throw new Error(log_entry); throw { msg: 'earlyExit', retValue: (new ShellString('', state.error, state.errorCode)) }; } - - if (msg.length > 0) - log(log_entry); } exports.error = error; diff --git a/test/common.js b/test/common.js index e7e1d93..b450ae2 100644 --- a/test/common.js +++ b/test/common.js @@ -94,6 +94,11 @@ assert.ok(typeof result.stderr === 'undefined'); assert.ok(result.to); assert.ok(result.toEnd); +// Commands that fail will still output error messages to stderr +result = shell.exec(JSON.stringify(process.execPath) + ' -e "require(\'../global\'); ls(\'noexist\'); cd(\'noexist\');"'); +assert.equal(result.stdout, ''); +assert.equal(result.stderr, 'ls: no such file or directory: noexist\ncd: no such file or directory: noexist\n'); + shell.exit(123);