mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
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
This commit is contained in:
parent
d22195e741
commit
68b388a93a
2 changed files with 12 additions and 2 deletions
|
@ -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,
|
||||
|
|
|
@ -1175,3 +1175,8 @@ Deno.test("process.cpuUsage()", () => {
|
|||
assert(typeof cpuUsage.user === "number");
|
||||
assert(typeof cpuUsage.system === "number");
|
||||
});
|
||||
|
||||
Deno.test("process.stdout.columns writable", () => {
|
||||
process.stdout.columns = 80;
|
||||
assertEquals(process.stdout.columns, 80);
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue