mirror of
https://github.com/denoland/deno.git
synced 2025-09-26 12:19:12 +00:00
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>
This commit is contained in:
parent
60688c563e
commit
4eedac3604
11 changed files with 92 additions and 33 deletions
37
cli/tsc/dts/lib.deno.ns.d.ts
vendored
37
cli/tsc/dts/lib.deno.ns.d.ts
vendored
|
@ -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<Uint8Array>;
|
||||
/**
|
||||
* 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<Uint8Array>;
|
||||
/**
|
||||
* 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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue