mirror of
https://github.com/denoland/deno.git
synced 2025-01-03 04:48:52 -05:00
4eedac3604
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>
27 lines
603 B
JavaScript
27 lines
603 B
JavaScript
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
import { core, internals, primordials } from "ext:core/mod.js";
|
|
const {
|
|
op_console_size,
|
|
op_is_terminal,
|
|
} = core.ensureFastOps(true);
|
|
const {
|
|
Uint32Array,
|
|
} = primordials;
|
|
|
|
const size = new Uint32Array(2);
|
|
|
|
function consoleSize() {
|
|
op_console_size(size);
|
|
return { columns: size[0], rows: size[1] };
|
|
}
|
|
|
|
function isatty(rid) {
|
|
internals.warnOnDeprecatedApi(
|
|
"Deno.isatty()",
|
|
new Error().stack,
|
|
"Use `stdStream.isTerminal()` instead.",
|
|
);
|
|
return op_is_terminal(rid);
|
|
}
|
|
|
|
export { consoleSize, isatty };
|