mirror of
https://gitea.toothfairyai.com/ToothFairyAI/tf_code.git
synced 2026-03-30 05:43:55 +00:00
refactor: replace Bun.stdin.text with Node.js stream reading
This commit is contained in:
parent
a9bf1c0505
commit
ae5c9ed3dd
@ -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) {
|
||||
UI.error("You must provide a message or a command")
|
||||
|
||||
@ -53,7 +53,13 @@ async function target() {
|
||||
}
|
||||
|
||||
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 (!piped) return value
|
||||
return piped + "\n" + value
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user