-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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(std/node/process)-stdin-stdout-stderr #7184
Changes from 11 commits
2cb0948
3e129fc
000e71a
2b4e3c9
10889b4
da8ceb9
4344074
c9bb055
a36d482
ab80097
db33a6a
49d0f15
f50bfde
997bae9
3d1d0d6
1be85a6
eda17e3
7c09ba7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,6 +38,30 @@ export const process = { | |
platform, | ||
version, | ||
versions, | ||
get stderr() { | ||
return { | ||
...Deno.stderr, | ||
get isTTY(): boolean { | ||
return Deno.isatty(this.rid); | ||
}, | ||
}; | ||
}, | ||
get stdin() { | ||
return { | ||
...Deno.stdin, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto |
||
get isTTY(): boolean { | ||
return Deno.isatty(this.rid); | ||
}, | ||
}; | ||
}, | ||
get stdout() { | ||
return { | ||
...Deno.stdout, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ditto. |
||
get isTTY(): boolean { | ||
return Deno.isatty(this.rid); | ||
}, | ||
}; | ||
}, | ||
|
||
/** https://nodejs.org/api/process.html#process_process_events */ | ||
// on is not exported by node, it is only available within process: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,8 +15,11 @@ Deno.test({ | |
allKeys.delete("process"); | ||
// without esm default | ||
allKeys.delete("default"); | ||
// with on, which is not exported via * | ||
// with on, stdin, stderr, and stdout, which is not exported via * | ||
allKeys.add("on"); | ||
allKeys.add("stdin"); | ||
allKeys.add("stderr"); | ||
allKeys.add("stdout"); | ||
const allStr = Array.from(allKeys).sort().join(" "); | ||
assertEquals(Object.keys(all.default).sort().join(" "), allStr); | ||
assertEquals(Object.keys(all.process).sort().join(" "), allStr); | ||
|
@@ -120,3 +123,33 @@ Deno.test({ | |
assertEquals(typeof env.PATH, "string"); | ||
}, | ||
}); | ||
|
||
Deno.test({ | ||
name: "process.stdin", | ||
fn() { | ||
assertEquals(typeof process.stdin.rid, "number"); | ||
assertEquals(process.stdin.rid, Deno.stdin.rid); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In Node there isn't a process.stdin.rid There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay! I’ll get peep everything on node.process and replicate it more explicitly instead of spreading denos stdio. |
||
// TODO(jayhelton) Uncomment out this assertion once PTY is supported | ||
//assert(process.stdin.isTTY); | ||
}, | ||
}); | ||
|
||
Deno.test({ | ||
name: "process.stdout", | ||
fn() { | ||
assertEquals(typeof process.stdout.rid, "number"); | ||
assertEquals(process.stdout.rid, Deno.stdout.rid); | ||
// TODO(jayhelton) Uncomment out this assertion once PTY is supported | ||
// assert(process.stdout.isTTY); | ||
}, | ||
}); | ||
|
||
Deno.test({ | ||
name: "process.stderr", | ||
fn() { | ||
assertEquals(typeof process.stderr.rid, "number"); | ||
assertEquals(process.stderr.rid, Deno.stderr.rid); | ||
// TODO(jayhelton) Uncomment out this assertion once PTY is supported | ||
// assert(process.stderr.isTTY); | ||
}, | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Be explicit about the properties you want to expose here, this is very brittle and can break anytime additions or changes are made to Deno.stderr (Hasn't happened yet but theoretically it can happen).