mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
fix: validate integer values in Deno.exitCode
setter (#24068)
This commit is contained in:
parent
754f21f0cd
commit
eda43c46de
5 changed files with 90 additions and 135 deletions
|
@ -22,7 +22,8 @@ import {
|
|||
const {
|
||||
Error,
|
||||
FunctionPrototypeBind,
|
||||
NumberParseInt,
|
||||
NumberIsInteger,
|
||||
RangeError,
|
||||
SymbolFor,
|
||||
TypeError,
|
||||
} = primordials;
|
||||
|
@ -102,13 +103,17 @@ function getExitCode() {
|
|||
}
|
||||
|
||||
function setExitCode(value) {
|
||||
const code = NumberParseInt(value, 10);
|
||||
if (typeof code !== "number") {
|
||||
if (typeof value !== "number") {
|
||||
throw new TypeError(
|
||||
`Exit code must be a number, got: ${code} (${typeof code}).`,
|
||||
`Exit code must be a number, got: ${value} (${typeof value})`,
|
||||
);
|
||||
}
|
||||
op_set_exit_code(code);
|
||||
if (!NumberIsInteger(value)) {
|
||||
throw new RangeError(
|
||||
`Exit code must be an integer, got: ${value}`,
|
||||
);
|
||||
}
|
||||
op_set_exit_code(value);
|
||||
}
|
||||
|
||||
function setEnv(key, value) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue