From f21311b48f62f0063e3c729fc8a6a5dcdc4da7f9 Mon Sep 17 00:00:00 2001 From: Arnau Orriols <4871949+arnauorriols@users.noreply.github.com> Date: Fri, 26 Jan 2024 02:22:15 +0100 Subject: [PATCH] fix: 1.40 deprecation warnings (#246) --- deployctl.ts | 6 +++--- deps.ts | 2 +- src/subcommands/top.ts | 4 ++-- src/utils/mod.ts | 12 ++++++++++++ src/version.ts | 2 +- 5 files changed, 19 insertions(+), 7 deletions(-) diff --git a/deployctl.ts b/deployctl.ts index 592ec3c6..8d7ef6cf 100755 --- a/deployctl.ts +++ b/deployctl.ts @@ -2,7 +2,6 @@ // Copyright 2021 Deno Land Inc. All rights reserved. MIT license. -// deno-lint-ignore-file no-deprecated-deno-api import { semverGreaterThanOrEquals, setColorEnabled } from "./deps.ts"; import { Args, parseArgs } from "./src/args.ts"; import { error } from "./src/error.ts"; @@ -16,6 +15,7 @@ import { fetchReleases, getConfigPaths } from "./src/utils/info.ts"; import configFile from "./src/config_file.ts"; import inferConfig from "./src/config_inference.ts"; import { wait } from "./src/utils/spinner.ts"; +import { isTerminal } from "./src/utils/mod.ts"; const help = `deployctl ${VERSION} Command line tool for Deno Deploy. @@ -42,7 +42,7 @@ const args = parseArgs(Deno.args); setColoring(args); -if (Deno.isatty(Deno.stdin.rid)) { +if (isTerminal(Deno.stdin)) { let latestVersion; // Get the path to the update information json file. const { updatePath } = getConfigPaths(); @@ -160,7 +160,7 @@ function setColoring(args: Args) { } function setAutoColoring() { - if (Deno.isatty(Deno.stdout.rid)) { + if (isTerminal(Deno.stdout)) { setColorEnabled(true); } else { setColorEnabled(false); diff --git a/deps.ts b/deps.ts index bd020919..e2b82631 100644 --- a/deps.ts +++ b/deps.ts @@ -40,6 +40,6 @@ export { Spinner, type SpinnerOptions, wait, -} from "https://raw.githubusercontent.com/denosaurs/wait/9471d5cb37f31065fd867c85a8b1511091a24ee7/mod.ts"; +} from "https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/mod.ts"; export * as tty from "https://deno.land/x/tty@0.1.4/mod.ts"; diff --git a/src/subcommands/top.ts b/src/subcommands/top.ts index 43410215..34271e50 100644 --- a/src/subcommands/top.ts +++ b/src/subcommands/top.ts @@ -1,6 +1,5 @@ // Copyright 2021 Deno Land Inc. All rights reserved. MIT license. -// deno-lint-ignore-file no-deprecated-deno-api import { Args } from "../args.ts"; import { API } from "../utils/api.ts"; import TokenProvisioner from "../utils/access_token.ts"; @@ -9,6 +8,7 @@ import { delay, encodeHex, tty } from "../../deps.ts"; import { error } from "../error.ts"; import { ProjectStats } from "../utils/api_types.ts"; import { sha256 } from "../utils/hashing_encoding.ts"; +import { isTerminal } from "../utils/mod.ts"; const help = ` Project monitoring (ALPHA) @@ -58,7 +58,7 @@ export default async function topSubcommand(args: Args) { format = args.format; break; case undefined: - format = Deno.isatty(Deno.stdout.rid) ? "table" : "json"; + format = isTerminal(Deno.stdout) ? "table" : "json"; break; default: error( diff --git a/src/utils/mod.ts b/src/utils/mod.ts index bb2a97c0..f154f8b1 100644 --- a/src/utils/mod.ts +++ b/src/utils/mod.ts @@ -1,4 +1,16 @@ +import { semverGreaterThanOrEquals } from "../../deps.ts"; + export { parseEntrypoint } from "./entrypoint.ts"; export { API, APIError } from "./api.ts"; export { walk } from "./walk.ts"; export { fromFileUrl, resolve } from "../../deps.ts"; + +// deno-lint-ignore no-explicit-any +export function isTerminal(stream: any) { + if (semverGreaterThanOrEquals(Deno.version.deno, "1.40.0")) { + return stream.isTerminal(); + } else { + // deno-lint-ignore no-deprecated-deno-api + return Deno.isatty(stream.rid); + } +} diff --git a/src/version.ts b/src/version.ts index d1e0d9d9..539ac7e8 100644 --- a/src/version.ts +++ b/src/version.ts @@ -1,3 +1,3 @@ -export const VERSION = "1.10.2"; +export const VERSION = "1.10.3"; export const MINIMUM_DENO_VERSION = "1.28.3";