Skip to content

Commit ebdc245

Browse files
committed
Use full signal constants in with-env
1 parent 5934aa1 commit ebdc245

1 file changed

Lines changed: 2 additions & 8 deletions

File tree

scripts/with-env.mjs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/usr/bin/env node
22
import { spawn } from "node:child_process";
3+
import { constants as osConstants } from "node:os";
34
import process from "node:process";
45

56
const usage = () => {
@@ -38,21 +39,14 @@ const child = spawn(command, args, {
3839
shell: process.platform === "win32",
3940
});
4041

41-
const SIGNAL_EXIT_CODES = {
42-
SIGHUP: 1,
43-
SIGINT: 2,
44-
SIGKILL: 9,
45-
SIGTERM: 15,
46-
};
47-
4842
child.on("error", (error) => {
4943
console.error(`with-env: failed to start "${command}": ${error.message}`);
5044
process.exit(1);
5145
});
5246

5347
child.on("exit", (code, signal) => {
5448
if (signal) {
55-
process.exit(128 + (SIGNAL_EXIT_CODES[signal] ?? 1));
49+
process.exit(128 + (osConstants.signals?.[signal] ?? 1));
5650
}
5751
process.exit(code ?? 1);
5852
});

0 commit comments

Comments
 (0)