From d1c2d6b25ceaeb58513d8687ba7945447adb6618 Mon Sep 17 00:00:00 2001 From: Dylan Conway <35280289+dylan-conway@users.noreply.github.com> Date: Mon, 28 Aug 2023 20:08:08 -0700 Subject: use `options.fd` if provided for `fs.Read/WriteStream` (#4378) * use `options.fd` over path * tests * fix `@clack/prompts` * == null --- src/js/node/tty.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/js/node/tty.js') diff --git a/src/js/node/tty.js b/src/js/node/tty.js index 09010e8fc..d5645c6da 100644 --- a/src/js/node/tty.js +++ b/src/js/node/tty.js @@ -4,7 +4,9 @@ function ReadStream(fd) { if (!(this instanceof ReadStream)) return new ReadStream(fd); if (fd >> 0 !== fd || fd < 0) throw new RangeError("fd must be a positive integer"); - const stream = require("node:fs").ReadStream.call(this, `/dev/fd/${fd}`); + const stream = require("node:fs").ReadStream.call(this, "", { + fd, + }); stream.isRaw = false; stream.isTTY = isatty(stream.fd); @@ -93,7 +95,9 @@ function WriteStream(fd) { if (!(this instanceof WriteStream)) return new WriteStream(fd); if (fd >> 0 !== fd || fd < 0) throw new RangeError("fd must be a positive integer"); - const stream = require("node:fs").WriteStream.call(this, `/dev/fd/${fd}`); + const stream = require("node:fs").WriteStream.call(this, "", { + fd, + }); stream.columns = undefined; stream.rows = undefined; -- cgit v1.2.3