1
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2024-12-20 14:24:48 -05:00
denoland-deno/tests/testdata/run/node_process_stdin_unref_with_pty.js
Yoshiya Hinosawa 8178f758bc
fix(ext/node): support process.stdin.unref() (#22865)
This PR adds private `[REF]()` and `[UNREF]()` methods to Stdin class,
and call them from Node.js polyfill layer (`TTY` class). This enables
`process.stdin.unref()` and `process.stdin.ref()` for the case when
stdin is terminal.

closes #21796
2024-04-27 20:25:18 +09:00

14 lines
360 B
JavaScript

import process from "node:process";
import util from "node:util";
console.log("START");
globalThis.addEventListener("unload", () => console.log("END"));
const args = util.parseArgs({ options: { unref: { type: "boolean" } } });
// call stdin.unref if --unref is passed
if (args.values.unref) {
process.stdin.unref();
}
process.stdin.pipe(process.stdout);