summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/process.ts
diff options
context:
space:
mode:
Diffstat (limited to 'ext/node/polyfills/process.ts')
-rw-r--r--ext/node/polyfills/process.ts17
1 files changed, 14 insertions, 3 deletions
diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts
index c495a90bb..575d8dfb1 100644
--- a/ext/node/polyfills/process.ts
+++ b/ext/node/polyfills/process.ts
@@ -76,15 +76,16 @@ const notImplementedEvents = [
];
export const argv: string[] = [];
+let globalProcessExitCode: number | undefined = undefined;
/** https://nodejs.org/api/process.html#process_process_exit_code */
export const exit = (code?: number | string) => {
if (code || code === 0) {
if (typeof code === "string") {
const parsedCode = parseInt(code);
- process.exitCode = isNaN(parsedCode) ? undefined : parsedCode;
+ globalProcessExitCode = isNaN(parsedCode) ? undefined : parsedCode;
} else {
- process.exitCode = code;
+ globalProcessExitCode = code;
}
}
@@ -426,7 +427,17 @@ class Process extends EventEmitter {
_exiting = _exiting;
/** https://nodejs.org/api/process.html#processexitcode_1 */
- exitCode: undefined | number = undefined;
+ get exitCode() {
+ return globalProcessExitCode;
+ }
+
+ set exitCode(code: number | undefined) {
+ globalProcessExitCode = code;
+ code = parseInt(code) || 0;
+ if (!isNaN(code)) {
+ ops.op_set_exit_code(code);
+ }
+ }
// Typed as any to avoid importing "module" module for types
// deno-lint-ignore no-explicit-any