Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(node): add ppid getter for node:process #22167

Merged
merged 4 commits into from
Feb 1, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
add process.ppid for node:process
  • Loading branch information
magurotuna committed Jan 29, 2024
commit 0c207dd6a7df20143a02997004572a8b6b82953d
12 changes: 12 additions & 0 deletions cli/tests/unit_node/process_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably can be removed now?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, just removed :)

assertEquals(process.ppid, Number(Deno.ppid));
},
});

Deno.test({
name: "process.on",
async fn() {
Expand Down
9 changes: 9 additions & 0 deletions ext/node/polyfills/process.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading