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 /runtime/js/41_prompt.js | |
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 'runtime/js/41_prompt.js')
-rw-r--r-- | runtime/js/41_prompt.js | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/runtime/js/41_prompt.js b/runtime/js/41_prompt.js index fce1ac9ac..d0e065538 100644 --- a/runtime/js/41_prompt.js +++ b/runtime/js/41_prompt.js @@ -9,14 +9,13 @@ const { Uint8Array, } = primordials; -import { isatty } from "ext:runtime/40_tty.js"; import { stdin } from "ext:deno_io/12_io.js"; const LF = StringPrototypeCharCodeAt("\n", 0); const CR = StringPrototypeCharCodeAt("\r", 0); function alert(message = "Alert") { - if (!isatty(stdin.rid)) { + if (!stdin.isTerminal()) { return; } @@ -26,7 +25,7 @@ function alert(message = "Alert") { } function confirm(message = "Confirm") { - if (!isatty(stdin.rid)) { + if (!stdin.isTerminal()) { return false; } @@ -40,7 +39,7 @@ function confirm(message = "Confirm") { function prompt(message = "Prompt", defaultValue) { defaultValue ??= ""; - if (!isatty(stdin.rid)) { + if (!stdin.isTerminal()) { return null; } |