mirror of
https://github.com/cline/cline.git
synced 2026-09-21 05:10:09 +08:00
error cline if someone piped in empty text (#9038)
Co-authored-by: Max Paulus 🥪 <max@cline.bot>
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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", () => {
|
||||
|
||||
Reference in New Issue
Block a user