File tree 1 file changed +17
-2
lines changed
1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -68,7 +68,22 @@ export function showCursor() {
68
68
Deno . stderr . writeSync ( encoder . encode ( "\x1B[?25h" ) ) ;
69
69
}
70
70
71
- export const isOutputTty = safeConsoleSize ( ) != null && Deno . stderr . isTerminal ( ) ;
71
+ export const isOutputTty = safeConsoleSize ( ) != null && isTerminal ( Deno . stderr ) ;
72
+
73
+ function isTerminal ( pipe : { isTerminal ?( ) : boolean ; rid ?: number } ) {
74
+ if ( typeof pipe . isTerminal === "function" ) {
75
+ return pipe . isTerminal ( ) ;
76
+ } else if (
77
+ pipe . rid != null &&
78
+ // deno-lint-ignore no-deprecated-deno-api
79
+ typeof Deno . isatty === "function"
80
+ ) {
81
+ // deno-lint-ignore no-deprecated-deno-api
82
+ return Deno . isatty ( pipe . rid ) ;
83
+ } else {
84
+ throw new Error ( "Unsupported pipe." ) ;
85
+ }
86
+ }
72
87
73
88
export function resultOrExit < T > ( result : T | undefined ) : T {
74
89
if ( result == null ) {
@@ -86,7 +101,7 @@ export interface SelectionOptions<TReturn> {
86
101
}
87
102
88
103
export function createSelection < TReturn > ( options : SelectionOptions < TReturn > ) : Promise < TReturn | undefined > {
89
- if ( ! isOutputTty || ! Deno . stdin . isTerminal ( ) ) {
104
+ if ( ! isOutputTty || ! isTerminal ( Deno . stdin ) ) {
90
105
throw new Error ( `Cannot prompt when not a tty. (Prompt: '${ options . message } ')` ) ;
91
106
}
92
107
if ( safeConsoleSize ( ) == null ) {
You can’t perform that action at this time.
0 commit comments