Skip to content

Commit 32a32d6

Browse files
committed
build: delete the dist-schema/ before generating it
1 parent 53f6b5c commit 32a32d6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

scripts/build-schema.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,15 @@ function _mkdirp(p: string) {
2323
}
2424

2525

26+
function _rimraf(p: string) {
27+
glob.sync(path.join(p, '**/*'), { dot: true, nodir: true })
28+
.forEach(p => fs.unlinkSync(p));
29+
glob.sync(path.join(p, '**/*'), { dot: true })
30+
.sort((a, b) => b.length - a.length)
31+
.forEach(p => fs.rmdirSync(p));
32+
}
33+
34+
2635
export default async function(
2736
argv: { },
2837
logger: logging.Logger,
@@ -35,8 +44,12 @@ export default async function(
3544
'**/package.json',
3645
],
3746
});
47+
const dist = path.join(__dirname, '../dist-schema');
3848

3949
const quicktypeRunner = require('../tools/quicktype_runner');
50+
logger.info('Removing dist-schema/...');
51+
_rimraf(dist);
52+
4053
logger.info('Generating JSON Schema....');
4154

4255
for (const fileName of allJsonFiles) {
@@ -53,7 +66,7 @@ export default async function(
5366
continue;
5467
}
5568
const tsContent = await quicktypeRunner.generate(fileName);
56-
const tsPath = path.join(__dirname, '../dist-schema', fileName.replace(/\.json$/, '.ts'));
69+
const tsPath = path.join(dist, fileName.replace(/\.json$/, '.ts'));
5770

5871
_mkdirp(path.dirname(tsPath));
5972
fs.writeFileSync(tsPath, tsContent, 'utf-8');

0 commit comments

Comments
 (0)