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/assertion_error.ts | |
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/assertion_error.ts')
-rw-r--r-- | ext/node/polyfills/assertion_error.ts | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/node/polyfills/assertion_error.ts b/ext/node/polyfills/assertion_error.ts index bec1f6ba5..ff1168dc3 100644 --- a/ext/node/polyfills/assertion_error.ts +++ b/ext/node/polyfills/assertion_error.ts @@ -163,7 +163,7 @@ export function createErrDiff( // If the stderr is a tty and the input length is lower than the current // columns per line, add a mismatch indicator below the output. If it is // not a tty, use a default value of 80 characters. - const maxLength = Deno.isatty(io.stderr.rid) ? getConsoleWidth() : 80; + const maxLength = io.stderr.isTerminal() ? getConsoleWidth() : 80; if (inputLength < maxLength) { while (actualRaw[i] === expectedRaw[i]) { i++; @@ -406,7 +406,7 @@ export class AssertionError extends Error { if (message != null) { super(String(message)); } else { - if (Deno.isatty(io.stderr.rid)) { + if (io.stderr.isTerminal()) { // Reset on each call to make sure we handle dynamically set environment // variables correct. if (Deno.noColor) { |