Fix stdin reading behavior in CI environments with TTY detection
This commit is contained in:
parent
b98b9b495f
commit
09279e888b
1 changed files with 7 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue