diff options
author | Marvin Hagemeister <marvin@deno.com> | 2024-10-11 19:14:10 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-10-11 19:14:10 +0200 |
commit | 9117a9a43cba86d3112f86b10c5ea77baa2c6007 (patch) | |
tree | 21cce1fb7525ae8dc4863d7feb24d3e8688c7f60 /ext/node/polyfills/_process/streams.mjs | |
parent | 94b588ce6624ae2f2ed648c7b1a479a10513542f (diff) |
fix(node): make `process.stdout.isTTY` writable (#26130)
Fixes https://github.com/denoland/deno/issues/26123
Diffstat (limited to 'ext/node/polyfills/_process/streams.mjs')
-rw-r--r-- | ext/node/polyfills/_process/streams.mjs | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/ext/node/polyfills/_process/streams.mjs b/ext/node/polyfills/_process/streams.mjs index 19c1c9c18..7936e82aa 100644 --- a/ext/node/polyfills/_process/streams.mjs +++ b/ext/node/polyfills/_process/streams.mjs @@ -63,6 +63,10 @@ export function createWritableStdioStream(writer, name, warmup = false) { stream.destroySoon = stream.destroy; stream._isStdio = true; stream.once("close", () => writer?.close()); + + // We cannot call `writer?.isTerminal()` eagerly here + let getIsTTY = () => writer?.isTerminal(); + ObjectDefineProperties(stream, { columns: { __proto__: null, @@ -81,7 +85,11 @@ export function createWritableStdioStream(writer, name, warmup = false) { __proto__: null, enumerable: true, configurable: true, - get: () => writer?.isTerminal(), + // Allow users to overwrite it + get: () => getIsTTY(), + set: (value) => { + getIsTTY = () => value; + }, }, getWindowSize: { __proto__: null, |