Skip to content

Commit

Permalink
fix: shell.errorCode() honors shell.exit(code)
Browse files Browse the repository at this point in the history
This changes shell.exit() to use a wrapper function. This is so that
shell.errorCode() will have the correct error code after invoking
shell.exit(code). This isn't normally relevant, however a caller may be
listening for the exit status:

```
process.on('exit', code => {
  shell.exit(shell.errorCode());
});
```

Issue #1013
  • Loading branch information
nfischer committed Jun 26, 2023
1 parent a3a7e74 commit ad9b7a1
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,14 @@ require('./commands').forEach(function (command) {
//@ ### exit(code)
//@
//@ Exits the current process with the given exit `code`.
exports.exit = process.exit;
exports.exit = function exit(code) {
if (code) {
common.state.errorCode = code;
process.exit(code);
} else {
process.exit();
}
}

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 13 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 10 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 11 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 14 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 16 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 15 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 12 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 17 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 12 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 15 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 10 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 14 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 12 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 9 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 8 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 11 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 14 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 10 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 13 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 10 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 11 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 9 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 10 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 11 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 12 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 13 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 15 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 16 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 14 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 17 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 15 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 17 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 11 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 8 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 16 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 17 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 13 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 12 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 8 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 13 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 9 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on ubuntu-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 14 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 15 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 8 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 16 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 17 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 8 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 9 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 10 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 11 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 9 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on windows-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 12 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 13 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 14 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 16 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 15 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 17 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 8 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 9 on macos-latest

Missing semicolon

Check failure on line 39 in shell.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on macos-latest

Missing semicolon

//@include ./src/error.js
exports.error = require('./src/error');
Expand Down

0 comments on commit ad9b7a1

Please sign in to comment.