From 1748033b599f80391051342ba200e02cb87f486a Mon Sep 17 00:00:00 2001 From: Divy Srivastava Date: Sat, 6 Jan 2024 03:07:14 +0530 Subject: [PATCH] fix(ext/node): add WriteStream.isTTY (#21801) --- cli/tests/unit_node/tty_test.ts | 6 ++++++ ext/node/polyfills/tty.js | 1 + 2 files changed, 7 insertions(+) diff --git a/cli/tests/unit_node/tty_test.ts b/cli/tests/unit_node/tty_test.ts index ca88096856..c393da5b33 100644 --- a/cli/tests/unit_node/tty_test.ts +++ b/cli/tests/unit_node/tty_test.ts @@ -3,6 +3,7 @@ import { assert } from "../../../test_util/std/assert/mod.ts"; import { isatty } from "node:tty"; +import process from "node:process"; Deno.test("[node/tty isatty] returns true when fd is a tty, false otherwise", () => { assert(Deno.isatty(Deno.stdin.rid) === isatty(Deno.stdin.rid)); @@ -29,3 +30,8 @@ Deno.test("[node/tty isatty] returns false for irrelevant values", () => { assert(!isatty(null as any)); assert(!isatty(undefined as any)); }); + +Deno.test("[node/tty WriteStream.isTTY] returns true when fd is a tty", () => { + assert(Deno.isatty(Deno.stdin.rid) === process.stdin.isTTY); + assert(Deno.isatty(Deno.stdout.rid) === process.stdout.isTTY); +}); diff --git a/ext/node/polyfills/tty.js b/ext/node/polyfills/tty.js index e6c9c10c1f..a08d1ae37a 100644 --- a/ext/node/polyfills/tty.js +++ b/ext/node/polyfills/tty.js @@ -79,6 +79,7 @@ export class WriteStream extends Socket { const { columns, rows } = Deno.consoleSize(); this.columns = columns; this.rows = rows; + this.isTTY = true; } }