Skip to content

Commit

Permalink
refactor: remove use of Deno.isatty()
Browse files Browse the repository at this point in the history
  • Loading branch information
iuioiua committed Feb 1, 2024
1 parent 13357b9 commit 62ee535
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions ansi/cursor_position.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface CursorPositionOptions {
reader?: Deno.ReaderSync & {
readonly rid: number;
setRaw(mode: boolean, options?: Deno.SetRawOptions): void;
isTerminal(): boolean;
};
}

Expand Down
1 change: 1 addition & 0 deletions ansi/tty.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface TtyOptions {
reader?: Deno.ReaderSync & {
readonly rid: number;
setRaw(mode: boolean, options?: Deno.SetRawOptions): void;
isTerminal(): boolean;
};
}

Expand Down
4 changes: 3 additions & 1 deletion prompt/_generic_prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export interface GenericPromptOptions<TValue, TRawValue> {
reader?: Deno.Reader & {
readonly rid: number;
setRaw(mode: boolean, options?: Deno.SetRawOptions): void;
isTerminal(): boolean;
};
/** Change the prompt output stream. */
writer?: Deno.WriterSync;
Expand All @@ -89,6 +90,7 @@ export interface GenericPromptSettings<TValue, TRawValue>
reader: Deno.Reader & {
readonly rid: number;
setRaw(mode: boolean, options?: Deno.SetRawOptions): void;
isTerminal(): boolean;
};
writer: Deno.WriterSync;
}
Expand Down Expand Up @@ -356,7 +358,7 @@ export abstract class GenericPrompt<
/** Read user input from stdin. */
#readChar = async (): Promise<Uint8Array> => {
const buffer = new Uint8Array(8);
const isTty = Deno.isatty(this.settings.reader.rid);
const isTty = this.settings.reader.isTerminal();

if (isTty) {
this.settings.reader.setRaw(
Expand Down

0 comments on commit 62ee535

Please sign in to comment.