diff options
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/js/40_tty.js | 13 | ||||
-rw-r--r-- | runtime/js/41_prompt.js | 7 | ||||
-rw-r--r-- | runtime/ops/tty.rs | 4 |
3 files changed, 14 insertions, 10 deletions
diff --git a/runtime/js/40_tty.js b/runtime/js/40_tty.js index e94fc0374..97e35e0c3 100644 --- a/runtime/js/40_tty.js +++ b/runtime/js/40_tty.js @@ -1,9 +1,9 @@ // Copyright 2018-2024 the Deno authors. All rights reserved. MIT license. -import { core, primordials } from "ext:core/mod.js"; +import { core, internals, primordials } from "ext:core/mod.js"; const { op_console_size, - op_isatty, -} = core.ensureFastOps(); + op_is_terminal, +} = core.ensureFastOps(true); const { Uint32Array, } = primordials; @@ -16,7 +16,12 @@ function consoleSize() { } function isatty(rid) { - return op_isatty(rid); + internals.warnOnDeprecatedApi( + "Deno.isatty()", + new Error().stack, + "Use `stdStream.isTerminal()` instead.", + ); + return op_is_terminal(rid); } export { consoleSize, isatty }; 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; } diff --git a/runtime/ops/tty.rs b/runtime/ops/tty.rs index 6cc129883..40aa28494 100644 --- a/runtime/ops/tty.rs +++ b/runtime/ops/tty.rs @@ -52,7 +52,7 @@ deno_core::extension!( deno_tty, ops = [ op_stdin_set_raw, - op_isatty, + op_is_terminal, op_console_size, op_read_line_prompt ], @@ -210,7 +210,7 @@ fn op_stdin_set_raw( } #[op2(fast)] -fn op_isatty(state: &mut OpState, rid: u32) -> Result<bool, AnyError> { +fn op_is_terminal(state: &mut OpState, rid: u32) -> Result<bool, AnyError> { let handle = state.resource_table.get_handle(rid)?; Ok(handle.is_terminal()) } |