From 0554bb7739d3de424bfaa5b793e002e8f72cf0d2 Mon Sep 17 00:00:00 2001 From: Qu4k Date: Tue, 25 Aug 2020 21:10:50 +0200 Subject: [PATCH] feat: add is_interactive --- is_interactive.ts | 10 ++++++++++ mod.ts | 1 + 2 files changed, 11 insertions(+) create mode 100644 is_interactive.ts diff --git a/is_interactive.ts b/is_interactive.ts new file mode 100644 index 0000000..f8c3d48 --- /dev/null +++ b/is_interactive.ts @@ -0,0 +1,10 @@ +export function isInteractive(stream: { rid: number }): boolean { + if (Deno.permissions.query({ name: "env" })) { + return ( + Deno.isatty(stream.rid) && + Deno.env.get("TERM") !== "dumb" && + !Deno.env.get("CI") + ); + } + return Deno.isatty(stream.rid); +} diff --git a/mod.ts b/mod.ts index e30c816..91bba68 100644 --- a/mod.ts +++ b/mod.ts @@ -41,3 +41,4 @@ export * from "./tty_sync.ts"; export * from "./wcwidth.ts"; export * from "./ansi_regex.ts"; export * from "./strip_ansi.ts"; +export * from "./is_interactive.ts";