mirror of
https://github.com/sourcebot-dev/sourcebot.git
synced 2025-12-12 12:25:22 +00:00
Fix generate script race condition
This commit is contained in:
parent
98becf531a
commit
ba333ddb21
1 changed files with 7 additions and 5 deletions
|
|
@ -6,20 +6,22 @@ import { glob } from "glob";
|
|||
|
||||
|
||||
const BANNER_COMMENT = '// THIS IS A AUTO-GENERATED FILE. DO NOT MODIFY MANUALLY!\n';
|
||||
// const SCHEMAS: string[] = ["github.json", "shared.json"];
|
||||
|
||||
(async () => {
|
||||
const cwd = process.cwd();
|
||||
const schemasBasePath = path.resolve(`${cwd}/../../schemas`);
|
||||
const schemas = await glob(`${schemasBasePath}/**/*.json`)
|
||||
const outDirRoot = path.resolve(`${cwd}/src`);
|
||||
const schemas = await glob(`${schemasBasePath}/**/*.json`);
|
||||
|
||||
// Clean output directory first
|
||||
await rm(outDirRoot, { recursive: true, force: true });
|
||||
|
||||
|
||||
await Promise.all(schemas.map(async (schemaPath) => {
|
||||
const name = path.parse(schemaPath).name;
|
||||
const version = path.basename(path.dirname(schemaPath));
|
||||
const outDir = path.join(cwd, `src/${version}`);
|
||||
const outDir = path.join(outDirRoot, version);
|
||||
|
||||
// Clean output directory first
|
||||
await rm(outDir, { recursive: true, force: true });
|
||||
await mkdir(outDir, { recursive: true });
|
||||
|
||||
// Generate schema
|
||||
|
|
|
|||
Loading…
Reference in a new issue