Skip to content

Commit 3573019

Browse files
authored
fix(generate): make openapi output deterministic by formatting in-place (#23228)
1 parent fc5b353 commit 3573019

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ export const GenerateCommand = {
2525
]
2626
}
2727
}
28-
const json = JSON.stringify(specs, null, 2)
28+
const raw = JSON.stringify(specs, null, 2)
29+
30+
// Format through prettier so output is byte-identical to committed file
31+
// regardless of whether ./script/format.ts runs afterward.
32+
const prettier = await import("prettier")
33+
const babel = await import("prettier/plugins/babel")
34+
const estree = await import("prettier/plugins/estree")
35+
const format = prettier.format ?? prettier.default?.format
36+
const json = await format(raw, {
37+
parser: "json",
38+
plugins: [babel.default ?? babel, estree.default ?? estree],
39+
printWidth: 120,
40+
})
2941

3042
// Wait for stdout to finish writing before process.exit() is called
3143
await new Promise<void>((resolve, reject) => {

0 commit comments

Comments
 (0)