Skip to content

Commit 7652a96

Browse files
authored
fix: wait for stdout to flush in generate command (anomalyco#3821)
1 parent 901aae0 commit 7652a96

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

packages/opencode/src/cli/cmd/generate.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ export const GenerateCommand = {
55
command: "generate",
66
handler: async () => {
77
const specs = await Server.openapi()
8-
process.stdout.write(JSON.stringify(specs, null, 2))
8+
const json = JSON.stringify(specs, null, 2)
9+
10+
// Wait for stdout to finish writing before process.exit() is called
11+
await new Promise<void>((resolve, reject) => {
12+
process.stdout.write(json, (err) => {
13+
if (err) reject(err)
14+
else resolve()
15+
})
16+
})
917
},
1018
} satisfies CommandModule

0 commit comments

Comments
 (0)