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";