Skip to content

Commit

Permalink
fix: Slightly better stream type (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
eliassjogreen authored Sep 22, 2024
1 parent 927a50a commit 8944f71
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@denosaurs/tty",
"version": "0.2.0",
"version": "0.2.1",
"exports": {
".": "./mod.ts"
}
Expand Down
6 changes: 4 additions & 2 deletions is_interactive.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export async function isInteractiveAsync(
stream: { isTerminal(): boolean },
stream: Pick<typeof Deno.stdout, "isTerminal">,
): Promise<boolean> {
if (await Deno.permissions.query({ name: "env" })) {
return (
Expand All @@ -11,6 +11,8 @@ export async function isInteractiveAsync(
return stream.isTerminal();
}

export function isInteractive(stream: { isTerminal(): boolean }): boolean {
export function isInteractive(
stream: Pick<typeof Deno.stdout, "isTerminal">,
): boolean {
return stream.isTerminal();
}
4 changes: 2 additions & 2 deletions mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ export const PREV_LINE = "1F";
export const COLUMN = "1G"; // left?
export const HOME = "H";

export type SyncStream = Pick<typeof Deno.stdout, "writeSync">;
export type AsyncStream = Pick<typeof Deno.stdout, "write">;
export type SyncStream = Pick<typeof Deno.stdout, "writeSync" | "isTerminal">;
export type AsyncStream = Pick<typeof Deno.stdout, "write" | "isTerminal">;

export * from "./tty_async.ts";
export * from "./tty_sync.ts";
Expand Down

0 comments on commit 8944f71

Please sign in to comment.