Skip to content

Commit f21311b

Browse files
authored
fix: 1.40 deprecation warnings (#246)
1 parent 9085102 commit f21311b

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

deployctl.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
// Copyright 2021 Deno Land Inc. All rights reserved. MIT license.
44

5-
// deno-lint-ignore-file no-deprecated-deno-api
65
import { semverGreaterThanOrEquals, setColorEnabled } from "./deps.ts";
76
import { Args, parseArgs } from "./src/args.ts";
87
import { error } from "./src/error.ts";
@@ -16,6 +15,7 @@ import { fetchReleases, getConfigPaths } from "./src/utils/info.ts";
1615
import configFile from "./src/config_file.ts";
1716
import inferConfig from "./src/config_inference.ts";
1817
import { wait } from "./src/utils/spinner.ts";
18+
import { isTerminal } from "./src/utils/mod.ts";
1919

2020
const help = `deployctl ${VERSION}
2121
Command line tool for Deno Deploy.
@@ -42,7 +42,7 @@ const args = parseArgs(Deno.args);
4242

4343
setColoring(args);
4444

45-
if (Deno.isatty(Deno.stdin.rid)) {
45+
if (isTerminal(Deno.stdin)) {
4646
let latestVersion;
4747
// Get the path to the update information json file.
4848
const { updatePath } = getConfigPaths();
@@ -160,7 +160,7 @@ function setColoring(args: Args) {
160160
}
161161

162162
function setAutoColoring() {
163-
if (Deno.isatty(Deno.stdout.rid)) {
163+
if (isTerminal(Deno.stdout)) {
164164
setColorEnabled(true);
165165
} else {
166166
setColorEnabled(false);

deps.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ export {
4040
Spinner,
4141
type SpinnerOptions,
4242
wait,
43-
} from "https://raw.githubusercontent.com/denosaurs/wait/9471d5cb37f31065fd867c85a8b1511091a24ee7/mod.ts";
43+
} from "https://raw.githubusercontent.com/denosaurs/wait/453df8babdd72c59d865c5a616c5b04ee1154b9f/mod.ts";
4444

4545
export * as tty from "https://deno.land/x/tty@0.1.4/mod.ts";

src/subcommands/top.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Copyright 2021 Deno Land Inc. All rights reserved. MIT license.
22

3-
// deno-lint-ignore-file no-deprecated-deno-api
43
import { Args } from "../args.ts";
54
import { API } from "../utils/api.ts";
65
import TokenProvisioner from "../utils/access_token.ts";
@@ -9,6 +8,7 @@ import { delay, encodeHex, tty } from "../../deps.ts";
98
import { error } from "../error.ts";
109
import { ProjectStats } from "../utils/api_types.ts";
1110
import { sha256 } from "../utils/hashing_encoding.ts";
11+
import { isTerminal } from "../utils/mod.ts";
1212

1313
const help = `
1414
Project monitoring (ALPHA)
@@ -58,7 +58,7 @@ export default async function topSubcommand(args: Args) {
5858
format = args.format;
5959
break;
6060
case undefined:
61-
format = Deno.isatty(Deno.stdout.rid) ? "table" : "json";
61+
format = isTerminal(Deno.stdout) ? "table" : "json";
6262
break;
6363
default:
6464
error(

src/utils/mod.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,16 @@
1+
import { semverGreaterThanOrEquals } from "../../deps.ts";
2+
13
export { parseEntrypoint } from "./entrypoint.ts";
24
export { API, APIError } from "./api.ts";
35
export { walk } from "./walk.ts";
46
export { fromFileUrl, resolve } from "../../deps.ts";
7+
8+
// deno-lint-ignore no-explicit-any
9+
export function isTerminal(stream: any) {
10+
if (semverGreaterThanOrEquals(Deno.version.deno, "1.40.0")) {
11+
return stream.isTerminal();
12+
} else {
13+
// deno-lint-ignore no-deprecated-deno-api
14+
return Deno.isatty(stream.rid);
15+
}
16+
}

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export const VERSION = "1.10.2";
1+
export const VERSION = "1.10.3";
22

33
export const MINIMUM_DENO_VERSION = "1.28.3";

0 commit comments

Comments
 (0)