Skip to content

Commit f574297

Browse files
sapphi-rednatemoo-re
authored andcommitted
fix: uv_tty_init error on Windows (#235)
1 parent 3c200dd commit f574297

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

.changeset/lemon-monkeys-help.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@clack/core": patch
3+
---
4+
5+
Fix "TTY initialization failed: uv_tty_init returned EBADF (bad file descriptor)" error happening on Windows for non-tty terminals.

packages/core/src/prompts/prompt.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { stdin, stdout } from 'node:process';
22
import readline, { type Key, type ReadLine } from 'node:readline';
3-
import type { Readable, Writable } from 'node:stream';
4-
import { WriteStream } from 'node:tty';
3+
import type { Readable } from 'node:stream';
4+
import { Writable } from 'node:stream';
55
import { cursor, erase } from 'sisteransi';
66
import wrap from 'wrap-ansi';
77

@@ -133,7 +133,7 @@ export default class Prompt {
133133
);
134134
}
135135

136-
const sink = new WriteStream(0);
136+
const sink = new Writable();
137137
sink._write = (chunk, encoding, done) => {
138138
if (this._track) {
139139
this.value = this.rl?.line.replace(/\t/g, '');
@@ -150,6 +150,7 @@ export default class Prompt {
150150
tabSize: 2,
151151
prompt: '',
152152
escapeCodeTimeout: 50,
153+
terminal: true,
153154
});
154155
readline.emitKeypressEvents(this.input, this.rl);
155156
this.rl.prompt();

0 commit comments

Comments
 (0)