fix: error message now printed for fatal failures

This commit is contained in:
Nate Fischer 2016-03-31 22:09:22 -07:00
parent 2984b40b12
commit e87e29dd8d
2 changed files with 8 additions and 4 deletions

View File

@ -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;

View File

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