Skip to content
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
5 changes: 5 additions & 0 deletions .changeset/lemon-monkeys-help.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@clack/core": patch
---

Fix "TTY initialization failed: uv_tty_init returned EBADF (bad file descriptor)" error happening on Windows for non-tty terminals.
7 changes: 4 additions & 3 deletions packages/core/src/prompts/prompt.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { stdin, stdout } from 'node:process';
import readline, { type Key, type ReadLine } from 'node:readline';
import type { Readable, Writable } from 'node:stream';
import { WriteStream } from 'node:tty';
import type { Readable } from 'node:stream';
import { Writable } from 'node:stream';
import { cursor, erase } from 'sisteransi';
import wrap from 'wrap-ansi';

Expand Down Expand Up @@ -133,7 +133,7 @@ export default class Prompt {
);
}

const sink = new WriteStream(0);
const sink = new Writable();
sink._write = (chunk, encoding, done) => {
if (this._track) {
this.value = this.rl?.line.replace(/\t/g, '');
Expand All @@ -150,6 +150,7 @@ export default class Prompt {
tabSize: 2,
prompt: '',
escapeCodeTimeout: 50,
terminal: true,
});
readline.emitKeypressEvents(this.input, this.rl);
this.rl.prompt();
Expand Down