From 4eedac3604dad9f366d28868077eb02eddc22661 Mon Sep 17 00:00:00 2001 From: Asher Gomez Date: Wed, 24 Jan 2024 10:01:56 +1100 Subject: feat: `Deno.{stdin,stdout,stderr}.isTerminal()`, deprecate `Deno.isatty()` (#22011) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: Divy Srivastava --- cli/tsc/dts/lib.deno.ns.d.ts | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'cli/tsc/dts/lib.deno.ns.d.ts') diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index 483c5c3d0..bc3248d02 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -2612,6 +2612,17 @@ declare namespace Deno { * @category I/O */ setRaw(mode: boolean, options?: SetRawOptions): void; + /** + * Checks if `stdin` is a TTY (terminal). + * + * ```ts + * // This example is system and context specific + * Deno.stdin.isTerminal(); // true + * ``` + * + * @category I/O + */ + isTerminal(): boolean; }; /** A reference to `stdout` which can be used to write directly to `stdout`. * It implements the Deno specific {@linkcode Writer}, {@linkcode WriterSync}, @@ -2629,6 +2640,17 @@ declare namespace Deno { readonly rid: number; /** A writable stream interface to `stdout`. */ readonly writable: WritableStream; + /** + * Checks if `stdout` is a TTY (terminal). + * + * ```ts + * // This example is system and context specific + * Deno.stdout.isTerminal(); // true + * ``` + * + * @category I/O + */ + isTerminal(): boolean; }; /** A reference to `stderr` which can be used to write directly to `stderr`. * It implements the Deno specific {@linkcode Writer}, {@linkcode WriterSync}, @@ -2646,6 +2668,17 @@ declare namespace Deno { readonly rid: number; /** A writable stream interface to `stderr`. */ readonly writable: WritableStream; + /** + * Checks if `stderr` is a TTY (terminal). + * + * ```ts + * // This example is system and context specific + * Deno.stderr.isTerminal(); // true + * ``` + * + * @category I/O + */ + isTerminal(): boolean; }; /** @@ -2728,6 +2761,10 @@ declare namespace Deno { * Deno.close(ttyRid); * ``` * + * @deprecated Use `Deno.stdin.isTerminal()`, `Deno.stdout.isTerminal()` or + * `Deno.stderr.isTerminal()` instead. + * {@linkcode Deno.isatty} will be removed in v2.0.0. + * * @category I/O */ export function isatty(rid: number): boolean; -- cgit v1.2.3