summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/node/polyfills/internal/errors.ts30
-rw-r--r--ext/node/polyfills/os.ts2
-rw-r--r--ext/node/polyfills/process.ts4
3 files changed, 29 insertions, 7 deletions
diff --git a/ext/node/polyfills/internal/errors.ts b/ext/node/polyfills/internal/errors.ts
index 6529e9894..9ec9f9949 100644
--- a/ext/node/polyfills/internal/errors.ts
+++ b/ext/node/polyfills/internal/errors.ts
@@ -18,7 +18,7 @@
*/
import { primordials } from "ext:core/mod.js";
-const { JSONStringify } = primordials;
+const { JSONStringify, SymbolFor } = primordials;
import { format, inspect } from "ext:deno_node/internal/util/inspect.mjs";
import { codes } from "ext:deno_node/internal/error_codes.ts";
import {
@@ -421,8 +421,11 @@ export interface NodeSystemErrorCtx {
// `err.info`.
// The context passed into this error must have .code, .syscall and .message,
// and may have .path and .dest.
-class NodeSystemError extends NodeErrorAbstraction {
+class NodeSystemError extends Error {
+ code: string;
constructor(key: string, context: NodeSystemErrorCtx, msgPrefix: string) {
+ super();
+ this.code = key;
let message = `${msgPrefix}: ${context.syscall} returned ` +
`${context.code} (${context.message})`;
@@ -433,8 +436,6 @@ class NodeSystemError extends NodeErrorAbstraction {
message += ` => ${context.dest}`;
}
- super("SystemError", key, message);
-
captureLargerStackTrace(this);
Object.defineProperties(this, {
@@ -444,6 +445,18 @@ class NodeSystemError extends NodeErrorAbstraction {
writable: false,
configurable: true,
},
+ name: {
+ value: "SystemError",
+ enumerable: false,
+ writable: true,
+ configurable: true,
+ },
+ message: {
+ value: message,
+ enumerable: false,
+ writable: true,
+ configurable: true,
+ },
info: {
value: context,
enumerable: true,
@@ -502,6 +515,15 @@ class NodeSystemError extends NodeErrorAbstraction {
override toString() {
return `${this.name} [${this.code}]: ${this.message}`;
}
+
+ // deno-lint-ignore no-explicit-any
+ [SymbolFor("nodejs.util.inspect.custom")](_recurseTimes: number, ctx: any) {
+ return inspect(this, {
+ ...ctx,
+ getters: true,
+ customInspect: false,
+ });
+ }
}
function makeSystemErrorWithCode(key: string, msgPrfix: string) {
diff --git a/ext/node/polyfills/os.ts b/ext/node/polyfills/os.ts
index 753e39319..1cd466ec2 100644
--- a/ext/node/polyfills/os.ts
+++ b/ext/node/polyfills/os.ts
@@ -340,7 +340,7 @@ export function userInfo(
if (!_homedir) {
throw new ERR_OS_NO_HOMEDIR();
}
- let shell = isWindows ? (Deno.env.get("SHELL") || null) : null;
+ let shell = isWindows ? null : (Deno.env.get("SHELL") || null);
let username = op_node_os_username();
if (options?.encoding === "buffer") {
diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts
index ec8671122..8d5442935 100644
--- a/ext/node/polyfills/process.ts
+++ b/ext/node/polyfills/process.ts
@@ -84,9 +84,9 @@ let ProcessExitCode: undefined | null | string | number;
/** https://nodejs.org/api/process.html#process_process_exit_code */
export const exit = (code?: number | string) => {
if (code || code === 0) {
- denoOs.setExitCode(code);
+ process.exitCode = code;
} else if (Number.isNaN(code)) {
- denoOs.setExitCode(1);
+ process.exitCode = 1;
}
ProcessExitCode = denoOs.getExitCode();