diff options
author | Asher Gomez <ashersaupingomez@gmail.com> | 2024-01-24 10:01:56 +1100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-24 00:01:56 +0100 |
commit | 4eedac3604dad9f366d28868077eb02eddc22661 (patch) | |
tree | dda70cd31e731aad73e986002ef30acb84692dc4 /ext/node/polyfills/_process | |
parent | 60688c563e6d02813b021ad91132fe1eb3f103b6 (diff) |
feat: `Deno.{stdin,stdout,stderr}.isTerminal()`, deprecate `Deno.isatty()` (#22011)
This change:
1. Implements `Deno.stdin.isTerminal()`, `Deno.stdout.isTerminal()` and
`Deno.stderr.isTerminal()`.
2. Deprecates `Deno.isatty()` for removal in Deno v2, in favour of the
above instance methods.
3. Replaces use of `Deno.isatty()` with the above instance methods.
Related #21995
---------
Co-authored-by: Bartek IwaĆczuk <biwanczuk@gmail.com>
Co-authored-by: Divy Srivastava <dj.srivastava23@gmail.com>
Diffstat (limited to 'ext/node/polyfills/_process')
-rw-r--r-- | ext/node/polyfills/_process/streams.mjs | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/ext/node/polyfills/_process/streams.mjs b/ext/node/polyfills/_process/streams.mjs index 14d58fcab..166d099c8 100644 --- a/ext/node/polyfills/_process/streams.mjs +++ b/ext/node/polyfills/_process/streams.mjs @@ -46,30 +46,27 @@ export function createWritableStdioStream(writer, name) { enumerable: true, configurable: true, get: () => - Deno.isatty?.(writer?.rid) ? Deno.consoleSize?.().columns : undefined, + writer?.isTerminal() ? Deno.consoleSize?.().columns : undefined, }, rows: { enumerable: true, configurable: true, - get: () => - Deno.isatty?.(writer?.rid) ? Deno.consoleSize?.().rows : undefined, + get: () => writer?.isTerminal() ? Deno.consoleSize?.().rows : undefined, }, isTTY: { enumerable: true, configurable: true, - get: () => Deno.isatty?.(writer?.rid), + get: () => writer?.isTerminal(), }, getWindowSize: { enumerable: true, configurable: true, value: () => - Deno.isatty?.(writer?.rid) - ? Object.values(Deno.consoleSize?.()) - : undefined, + writer?.isTerminal() ? Object.values(Deno.consoleSize?.()) : undefined, }, }); - if (Deno.isatty?.(writer?.rid)) { + if (writer?.isTerminal()) { // These belong on tty.WriteStream(), but the TTY streams currently have // following problems: // 1. Using them here introduces a circular dependency. @@ -180,7 +177,7 @@ export const initStdin = () => { enumerable: true, configurable: true, get() { - return Deno.isatty?.(io.stdin.rid); + return io.stdin.isTerminal(); }, }); stdin._isRawMode = false; |