Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Slightly better stream type #3

Merged
merged 1 commit into from
Sep 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading