summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/node/polyfills/process.ts22
-rw-r--r--tests/unit_node/process_test.ts2
2 files changed, 15 insertions, 9 deletions
diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts
index 1a96af2a2..c281cab44 100644
--- a/ext/node/polyfills/process.ts
+++ b/ext/node/polyfills/process.ts
@@ -301,6 +301,16 @@ export function kill(pid: number, sig: string | number = "SIGTERM") {
return true;
}
+let getgid, getuid, geteuid;
+
+if (!isWindows) {
+ getgid = () => Deno.gid();
+ getuid = () => Deno.uid();
+ geteuid = () => op_geteuid();
+}
+
+export { geteuid, getgid, getuid };
+
// deno-lint-ignore no-explicit-any
function uncaughtExceptionHandler(err: any, origin: string) {
// The origin parameter can be 'unhandledRejection' or 'uncaughtException'
@@ -638,19 +648,13 @@ class Process extends EventEmitter {
}
/** This method is removed on Windows */
- getgid?(): number {
- return Deno.gid()!;
- }
+ getgid = getgid;
/** This method is removed on Windows */
- getuid?(): number {
- return Deno.uid()!;
- }
+ getuid = getuid;
/** This method is removed on Windows */
- geteuid?(): number {
- return op_geteuid();
- }
+ geteuid = geteuid;
// TODO(kt3k): Implement this when we added -e option to node compat mode
_eval: string | undefined = undefined;
diff --git a/tests/unit_node/process_test.ts b/tests/unit_node/process_test.ts
index 15ad052bf..6b90a30ba 100644
--- a/tests/unit_node/process_test.ts
+++ b/tests/unit_node/process_test.ts
@@ -6,6 +6,7 @@ import process, {
argv,
argv0 as importedArgv0,
env,
+ geteuid,
pid as importedPid,
platform as importedPlatform,
} from "node:process";
@@ -879,6 +880,7 @@ Deno.test("process.geteuid", () => {
if (Deno.build.os === "windows") {
assertEquals(process.geteuid, undefined);
} else {
+ assert(geteuid);
assert(typeof process.geteuid?.() === "number");
}
});