mirror of
https://github.com/anomalyco/opencode.git
synced 2026-07-10 04:28:31 +00:00
fix(opencode): await run event loop (#31389)
This commit is contained in:
parent
f43209bb8c
commit
0a7cb20e66
1 changed files with 11 additions and 2 deletions
|
|
@ -762,10 +762,15 @@ export const RunCommand = effectCmd({
|
|||
|
||||
if (!args.interactive) {
|
||||
const events = await client.event.subscribe()
|
||||
loop(client, events).catch((e) => {
|
||||
const completed = loop(client, events).catch((e) => {
|
||||
console.error(e)
|
||||
process.exit(1)
|
||||
process.exitCode = 1
|
||||
})
|
||||
async function finish() {
|
||||
if (args.attach) return
|
||||
const error = await completed
|
||||
if (error) process.exitCode = 1
|
||||
}
|
||||
|
||||
if (args.command) {
|
||||
const result = await client.session.command({
|
||||
|
|
@ -779,7 +784,9 @@ export const RunCommand = effectCmd({
|
|||
if (result.error) {
|
||||
if (!emit("error", { error: result.error })) UI.error(formatRunError(result.error))
|
||||
process.exitCode = 1
|
||||
return
|
||||
}
|
||||
await finish()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
@ -794,7 +801,9 @@ export const RunCommand = effectCmd({
|
|||
if (result.error) {
|
||||
if (!emit("error", { error: result.error })) UI.error(formatRunError(result.error))
|
||||
process.exitCode = 1
|
||||
return
|
||||
}
|
||||
await finish()
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue