summaryrefslogtreecommitdiff
path: root/ext/node/polyfills
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-10-14 14:00:02 +0530
committerGitHub <noreply@github.com>2024-10-14 14:00:02 +0530
commit68b388a93a3efe443fc5e306e883847bfb8551db (patch)
tree33d749c5488803d9b253b5cf19556412279fa92b /ext/node/polyfills
parentd22195e7416e7923e2868e3f250abb457f115fc6 (diff)
fix(ext/node): allow writing to tty columns (#26201)
Behave similar to Node.js where modifying `stdout.columns` doesn't really resize the terminal. Ref https://github.com/nodejs/node/issues/17529 Fixes https://github.com/denoland/deno/issues/26196
Diffstat (limited to 'ext/node/polyfills')
-rw-r--r--ext/node/polyfills/_process/streams.mjs9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/node/polyfills/_process/streams.mjs b/ext/node/polyfills/_process/streams.mjs
index 7936e82aa..3573956c9 100644
--- a/ext/node/polyfills/_process/streams.mjs
+++ b/ext/node/polyfills/_process/streams.mjs
@@ -66,14 +66,19 @@ export function createWritableStdioStream(writer, name, warmup = false) {
// We cannot call `writer?.isTerminal()` eagerly here
let getIsTTY = () => writer?.isTerminal();
+ const getColumns = () =>
+ stream._columns ||
+ (writer?.isTerminal() ? Deno.consoleSize?.().columns : undefined);
ObjectDefineProperties(stream, {
columns: {
__proto__: null,
enumerable: true,
configurable: true,
- get: () =>
- writer?.isTerminal() ? Deno.consoleSize?.().columns : undefined,
+ get: () => getColumns(),
+ set: (value) => {
+ stream._columns = value;
+ },
},
rows: {
__proto__: null,