Skip to content

Commit

Permalink
fix: Deno.consoleSize should handle if stdout is piped (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret authored Jan 28, 2024
1 parent e17e72c commit f171af1
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/shim-deno/src/deno/stable/functions/consoleSize.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
///<reference path="../lib.deno.d.ts" />

export const consoleSize: typeof Deno.consoleSize = function consoleSize() {
const { columns, rows } = process.stdout;
return { columns, rows };
const pipes = [process.stderr, process.stdout];
for (const pipe of pipes) {
if (pipe.columns != null) {
const { columns, rows } = pipe;
return { columns, rows };
}
}
// Both stdout and stderr were piped. This is not the best error message,
// but it's what Deno does. Opened: https://github.com/denoland/deno/issues/22162
throw new Error("The handle is invalid.");
};

0 comments on commit f171af1

Please sign in to comment.