Fix stdin reading behavior in CI environments with TTY detection

This commit is contained in:
Nate 2025-08-15 19:43:34 -07:00
parent b98b9b495f
commit 09279e888b

View file

@ -7,15 +7,20 @@ import * as fs from "fs";
export function readStdinSync(): string | null {
try {
// In test environments, don't attempt to read stdin to avoid hanging
// But allow CI environments to read stdin when it's clearly piped
if (
process.env.NODE_ENV === "test" ||
process.env.VITEST === "true" ||
process.env.JEST_WORKER_ID !== undefined ||
process.env.CI === "true"
process.env.JEST_WORKER_ID !== undefined
) {
return null;
}
// Special handling for CI environments - allow reading if stdin is clearly not a TTY
if (process.env.CI === "true" && process.stdin.isTTY === true) {
return null;
}
// Check if stdin is a TTY (interactive terminal)
if (process.stdin.isTTY === true) {
// Definitely a TTY, don't read