mirror of
https://github.com/denoland/deno.git
synced 2025-08-04 10:59:13 +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
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue