Skip to content

Commit ba333dd

Browse files
Fix generate script race condition
1 parent 98becf5 commit ba333dd

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

packages/schemas/tools/generate.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,22 @@ import { glob } from "glob";
66

77

88
const BANNER_COMMENT = '// THIS IS A AUTO-GENERATED FILE. DO NOT MODIFY MANUALLY!\n';
9-
// const SCHEMAS: string[] = ["github.json", "shared.json"];
109

1110
(async () => {
1211
const cwd = process.cwd();
1312
const schemasBasePath = path.resolve(`${cwd}/../../schemas`);
14-
const schemas = await glob(`${schemasBasePath}/**/*.json`)
13+
const outDirRoot = path.resolve(`${cwd}/src`);
14+
const schemas = await glob(`${schemasBasePath}/**/*.json`);
15+
16+
// Clean output directory first
17+
await rm(outDirRoot, { recursive: true, force: true });
18+
1519

1620
await Promise.all(schemas.map(async (schemaPath) => {
1721
const name = path.parse(schemaPath).name;
1822
const version = path.basename(path.dirname(schemaPath));
19-
const outDir = path.join(cwd, `src/${version}`);
23+
const outDir = path.join(outDirRoot, version);
2024

21-
// Clean output directory first
22-
await rm(outDir, { recursive: true, force: true });
2325
await mkdir(outDir, { recursive: true });
2426

2527
// Generate schema

0 commit comments

Comments
 (0)