mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-04-18 22:54:41 +00:00
refactor: replace Bun.stdin.text with Node.js stream reading
This commit is contained in:
@@ -337,7 +337,14 @@ export const RunCommand = cmd({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!process.stdin.isTTY) message += "\n" + (await Bun.stdin.text())
|
if (!process.stdin.isTTY) {
|
||||||
|
const stdinText = await new Promise<string>((resolve) => {
|
||||||
|
const chunks: Buffer[] = []
|
||||||
|
process.stdin.on("data", (chunk) => chunks.push(chunk))
|
||||||
|
process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8")))
|
||||||
|
})
|
||||||
|
message += "\n" + stdinText
|
||||||
|
}
|
||||||
|
|
||||||
if (message.trim().length === 0 && !args.command) {
|
if (message.trim().length === 0 && !args.command) {
|
||||||
UI.error("You must provide a message or a command")
|
UI.error("You must provide a message or a command")
|
||||||
|
|||||||
@@ -53,7 +53,13 @@ async function target() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function input(value?: string) {
|
async function input(value?: string) {
|
||||||
const piped = process.stdin.isTTY ? undefined : await Bun.stdin.text()
|
const piped = process.stdin.isTTY
|
||||||
|
? undefined
|
||||||
|
: await new Promise<string>((resolve) => {
|
||||||
|
const chunks: Buffer[] = []
|
||||||
|
process.stdin.on("data", (chunk) => chunks.push(chunk))
|
||||||
|
process.stdin.on("end", () => resolve(Buffer.concat(chunks).toString("utf-8")))
|
||||||
|
})
|
||||||
if (!value) return piped
|
if (!value) return piped
|
||||||
if (!piped) return value
|
if (!piped) return value
|
||||||
return piped + "\n" + value
|
return piped + "\n" + value
|
||||||
|
|||||||
Reference in New Issue
Block a user