mirror of
https://github.com/shelljs/shelljs.git
synced 2026-01-25 16:07:37 +00:00
fix: error message now printed for fatal failures
This commit is contained in:
parent
2984b40b12
commit
e87e29dd8d
@ -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;
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user