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 --- ext/io/12_io.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'ext/io') diff --git a/ext/io/12_io.js b/ext/io/12_io.js index d9b91a947..9f4a3766b 100644 --- a/ext/io/12_io.js +++ b/ext/io/12_io.js @@ -7,6 +7,7 @@ import { core, primordials } from "ext:core/mod.js"; const { op_stdin_set_raw, + op_is_terminal, } = core.ensureFastOps(true); const { Uint8Array, @@ -197,6 +198,10 @@ class Stdin { const cbreak = !!(options.cbreak ?? false); op_stdin_set_raw(mode, cbreak); } + + isTerminal() { + return op_is_terminal(this.rid); + } } class Stdout { @@ -227,6 +232,10 @@ class Stdout { } return this.#writable; } + + isTerminal() { + return op_is_terminal(this.rid); + } } class Stderr { @@ -257,6 +266,10 @@ class Stderr { } return this.#writable; } + + isTerminal() { + return op_is_terminal(this.rid); + } } const stdin = new Stdin(); -- cgit v1.2.3