error cline if someone piped in empty text (#9038)

Co-authored-by: Max Paulus 🥪 <max@cline.bot>
This commit is contained in:
Max
2026-02-02 16:27:54 -08:00
committed by GitHub
co-authored by Max Paulus 🥪
parent b1c5f0b811
commit bd7f2a29d6
2 changed files with 10 additions and 1 deletions
+6
View File
@@ -775,6 +775,12 @@ program
// Always check for piped stdin content
const stdinInput = await readStdinIfPiped()
// Error if stdin was piped but empty (e.g., `echo "" | cline`)
if (stdinInput === "") {
printWarning("Empty input received from stdin. Please provide content to process.")
exit(1)
}
// If no prompt argument, check if input is piped via stdin
let effectivePrompt = prompt
if (stdinInput) {
+4 -1
View File
@@ -40,7 +40,10 @@ export async function readStdinIfPiped(): Promise<string | null> {
process.stdin.on("end", () => {
clearTimeout(timeout)
resolve(data.trim() || null)
// Return empty string (not null) when stdin was piped but empty
// This allows callers to distinguish between "no piped input" (null)
// and "empty piped input" ("") for proper error handling
resolve(data.trim())
})
process.stdin.on("error", () => {