From 0c207dd6a7df20143a02997004572a8b6b82953d Mon Sep 17 00:00:00 2001 From: Yusuke Tanaka Date: Mon, 29 Jan 2024 14:26:42 +0900 Subject: [PATCH 1/2] add process.ppid for node:process --- cli/tests/unit_node/process_test.ts | 12 ++++++++++++ ext/node/polyfills/process.ts | 9 +++++++++ 2 files changed, 21 insertions(+) diff --git a/cli/tests/unit_node/process_test.ts b/cli/tests/unit_node/process_test.ts index 23bf738649ba84..7fe4e5f039deb0 100644 --- a/cli/tests/unit_node/process_test.ts +++ b/cli/tests/unit_node/process_test.ts @@ -121,6 +121,18 @@ Deno.test({ }, }); +Deno.test({ + name: "process.ppid", + fn() { + assertEquals(typeof process.ppid, "number"); + // TODO(magurotuna): Deno.ppid now is of type bigint (although its type + // declaration says it's a number). Until it's fixed, we compare + // `process.ppid` with the casted value. + // https://github.com/denoland/deno/issues/22166 + assertEquals(process.ppid, Number(Deno.ppid)); + }, +}); + Deno.test({ name: "process.on", async fn() { diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index 1edcccc009cbfe..f6f67f56a58889 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -564,6 +564,15 @@ class Process extends EventEmitter { return pid; } + /** https://nodejs.org/api/process.html#processppid */ + get ppid() { + // TODO(magurotuna): Deno.ppid now is of type bigint (although its type + // declaration says it's a number). Until it's fixed, we explicitly convert + // it to number to match Node.js behavior. + // https://github.com/denoland/deno/issues/22166 + return Number(Deno.ppid); + } + /** https://nodejs.org/api/process.html#process_process_platform */ get platform() { if (!platform) { From 1facba33292dec6315427d8c09206283811d53fc Mon Sep 17 00:00:00 2001 From: Yusuke Tanaka Date: Tue, 30 Jan 2024 15:38:15 +0900 Subject: [PATCH 2/2] remove cast --- cli/tests/unit_node/process_test.ts | 6 +----- ext/node/polyfills/process.ts | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/cli/tests/unit_node/process_test.ts b/cli/tests/unit_node/process_test.ts index 7fe4e5f039deb0..21f873260e14b8 100644 --- a/cli/tests/unit_node/process_test.ts +++ b/cli/tests/unit_node/process_test.ts @@ -125,11 +125,7 @@ Deno.test({ name: "process.ppid", fn() { assertEquals(typeof process.ppid, "number"); - // TODO(magurotuna): Deno.ppid now is of type bigint (although its type - // declaration says it's a number). Until it's fixed, we compare - // `process.ppid` with the casted value. - // https://github.com/denoland/deno/issues/22166 - assertEquals(process.ppid, Number(Deno.ppid)); + assertEquals(process.ppid, Deno.ppid); }, }); diff --git a/ext/node/polyfills/process.ts b/ext/node/polyfills/process.ts index 2321a0a2dcbda9..20399bdf90311f 100644 --- a/ext/node/polyfills/process.ts +++ b/ext/node/polyfills/process.ts @@ -560,11 +560,7 @@ class Process extends EventEmitter { /** https://nodejs.org/api/process.html#processppid */ get ppid() { - // TODO(magurotuna): Deno.ppid now is of type bigint (although its type - // declaration says it's a number). Until it's fixed, we explicitly convert - // it to number to match Node.js behavior. - // https://github.com/denoland/deno/issues/22166 - return Number(Deno.ppid); + return Deno.ppid; } /** https://nodejs.org/api/process.html#process_process_platform */