fix: wait for stdout to flush in generate command (#3821)
This commit is contained in:
parent
901aae09f7
commit
7652a96064
1 changed files with 9 additions and 1 deletions
|
|
@ -5,6 +5,14 @@ export const GenerateCommand = {
|
||||||
command: "generate",
|
command: "generate",
|
||||||
handler: async () => {
|
handler: async () => {
|
||||||
const specs = await Server.openapi()
|
const specs = await Server.openapi()
|
||||||
process.stdout.write(JSON.stringify(specs, null, 2))
|
const json = JSON.stringify(specs, null, 2)
|
||||||
|
|
||||||
|
// Wait for stdout to finish writing before process.exit() is called
|
||||||
|
await new Promise<void>((resolve, reject) => {
|
||||||
|
process.stdout.write(json, (err) => {
|
||||||
|
if (err) reject(err)
|
||||||
|
else resolve()
|
||||||
|
})
|
||||||
|
})
|
||||||
},
|
},
|
||||||
} satisfies CommandModule
|
} satisfies CommandModule
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue