Skip to content

Commit a9a8c43

Browse files
committed
fix: open /dev/tty directly in CLI prompts for curl pipe compatibility
When stdin is not a TTY (piped via curl | bash), readline gets EOF immediately. Now opens /dev/tty as the input stream so interactive prompts work regardless of how the script was invoked.
1 parent a8e3f31 commit a9a8c43

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

src/cli/prompts.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
1+
import { createReadStream } from "node:fs";
12
import { createInterface } from "node:readline";
23

3-
const rl = createInterface({ input: process.stdin, output: process.stdout });
4+
function getInput(): NodeJS.ReadableStream {
5+
// When piped (curl | bash), stdin is consumed by the pipe.
6+
// Open /dev/tty directly to read from the actual terminal.
7+
if (!process.stdin.isTTY) {
8+
try {
9+
return createReadStream("/dev/tty");
10+
} catch {
11+
// Windows or no TTY available — fall back to stdin
12+
}
13+
}
14+
return process.stdin;
15+
}
16+
17+
const rl = createInterface({ input: getInput(), output: process.stdout });
418

519
function ask(question: string): Promise<string> {
620
return new Promise((resolve) => {

0 commit comments

Comments
 (0)