summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/_process/streams.mjs
diff options
context:
space:
mode:
authorAsher Gomez <ashersaupingomez@gmail.com>2024-01-25 06:09:49 +1100
committerGitHub <noreply@github.com>2024-01-24 20:09:49 +0100
commit300eeb343efa00d9572d3befa47ca88fb51c7ac6 (patch)
tree419963878caaa24bfacaa9e9950931cb6cb2d4e8 /ext/node/polyfills/_process/streams.mjs
parent547468e625a7b040690a6f26901597b5672ac413 (diff)
feat: deprecate `Deno.{stdin,stdout,stderr}.rid` (#22073)
For removal in Deno v2. There are two issues: 1. Any script being run causes the output of `warnOnDeprecatedApi()` to be printed, even when none of the `rid` properties are called. 2. `.rid` of these classes is used in multiple tests. I'm not sure how to account for that. I thought of having `STDIN_RID`, and friends, constants, whose values can be shared between the tests and the classes themselves. Should we go with that or do something else? --------- Co-authored-by: Bartek IwaƄczuk <biwanczuk@gmail.com>
Diffstat (limited to 'ext/node/polyfills/_process/streams.mjs')
-rw-r--r--ext/node/polyfills/_process/streams.mjs13
1 files changed, 10 insertions, 3 deletions
diff --git a/ext/node/polyfills/_process/streams.mjs b/ext/node/polyfills/_process/streams.mjs
index 166d099c8..09c53eb9a 100644
--- a/ext/node/polyfills/_process/streams.mjs
+++ b/ext/node/polyfills/_process/streams.mjs
@@ -37,7 +37,14 @@ export function createWritableStdioStream(writer, name) {
}
},
});
- stream.fd = writer?.rid ?? -1;
+ let fd = -1;
+
+ if (writer instanceof io.Stdout) {
+ fd = io.STDOUT_RID;
+ } else if (writer instanceof io.Stderr) {
+ fd = io.STDERR_RID;
+ }
+ stream.fd = fd;
stream.destroySoon = stream.destroy;
stream._isStdio = true;
stream.once("close", () => writer?.close());
@@ -117,7 +124,7 @@ export function setReadStream(s) {
// https://github.com/nodejs/node/blob/v18.12.1/lib/internal/bootstrap/switches/is_main_thread.js#L189
/** Create process.stdin */
export const initStdin = () => {
- const fd = io.stdin?.rid;
+ const fd = io.stdin ? io.STDIN_RID : undefined;
let stdin;
const stdinType = _guessStdinType(fd);
@@ -172,7 +179,7 @@ export const initStdin = () => {
}
stdin.on("close", () => io.stdin?.close());
- stdin.fd = io.stdin?.rid ?? -1;
+ stdin.fd = io.stdin ? io.STDIN_RID : -1;
Object.defineProperty(stdin, "isTTY", {
enumerable: true,
configurable: true,