summaryrefslogtreecommitdiff
path: root/cli
diff options
context:
space:
mode:
Diffstat (limited to 'cli')
-rw-r--r--cli/bench/tty.js2
-rw-r--r--cli/diagnostics.rs1
-rw-r--r--cli/dts/lib.deno.ns.d.ts13
-rw-r--r--cli/dts/lib.deno.unstable.d.ts17
-rw-r--r--cli/tests/unit/tty_test.ts22
5 files changed, 22 insertions, 33 deletions
diff --git a/cli/bench/tty.js b/cli/bench/tty.js
index f86bcfd82..c01af255f 100644
--- a/cli/bench/tty.js
+++ b/cli/bench/tty.js
@@ -17,5 +17,5 @@ function bench(fun) {
}
bench(() => {
- Deno.consoleSize(0);
+ Deno.consoleSize();
});
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs
index 0fa35839e..7c27b62e5 100644
--- a/cli/diagnostics.rs
+++ b/cli/diagnostics.rs
@@ -35,7 +35,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"addSignalListener",
"bench",
"connect",
- "consoleSize",
"createHttpClient",
"kill",
"listen",
diff --git a/cli/dts/lib.deno.ns.d.ts b/cli/dts/lib.deno.ns.d.ts
index 0ac06dc62..eea3c7947 100644
--- a/cli/dts/lib.deno.ns.d.ts
+++ b/cli/dts/lib.deno.ns.d.ts
@@ -1901,6 +1901,19 @@ declare namespace Deno {
*/
export const File: typeof FsFile;
+ /** Gets the size of the console as columns/rows.
+ *
+ * ```ts
+ * const { columns, rows } = Deno.consoleSize();
+ * ```
+ *
+ * @category I/O
+ */
+ export function consoleSize(): {
+ columns: number;
+ rows: number;
+ };
+
/** @category I/O */
export interface SetRawOptions {
/**
diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts
index c687848ca..416176564 100644
--- a/cli/dts/lib.deno.unstable.d.ts
+++ b/cli/dts/lib.deno.unstable.d.ts
@@ -228,23 +228,6 @@ declare namespace Deno {
/** **UNSTABLE**: New API, yet to be vetted.
*
- * Gets the size of the console as columns/rows.
- *
- * ```ts
- * const { columns, rows } = Deno.consoleSize(Deno.stdout.rid);
- * ```
- *
- * @category I/O
- */
- export function consoleSize(
- rid: number,
- ): {
- columns: number;
- rows: number;
- };
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
* Returns the release version of the Operating System.
*
* ```ts
diff --git a/cli/tests/unit/tty_test.ts b/cli/tests/unit/tty_test.ts
index 8787db3e1..88b25d758 100644
--- a/cli/tests/unit/tty_test.ts
+++ b/cli/tests/unit/tty_test.ts
@@ -1,21 +1,15 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
-import { assert, assertThrows } from "./test_util.ts";
+import { assert } from "./test_util.ts";
// Note tests for Deno.stdin.setRaw is in integration tests.
-Deno.test({ permissions: { read: true } }, function consoleSizeFile() {
- const file = Deno.openSync("cli/tests/testdata/assets/hello.txt");
- assertThrows(() => {
- Deno.consoleSize(file.rid);
- }, Error);
- file.close();
-});
-
-Deno.test(function consoleSizeError() {
- assertThrows(() => {
- // Absurdly large rid.
- Deno.consoleSize(0x7fffffff);
- }, Deno.errors.BadResource);
+Deno.test(function consoleSize() {
+ if (!Deno.isatty(Deno.stdout.rid)) {
+ return;
+ }
+ const result = Deno.consoleSize();
+ assert(typeof result.columns !== "undefined");
+ assert(typeof result.rows !== "undefined");
});
Deno.test({ permissions: { read: true } }, function isatty() {