Clear out the build directory before compiling lang.

This commit is contained in:
Mike Cao 2020-09-19 09:12:44 -07:00
parent 56bf85acae
commit 2444144db9
3 changed files with 67 additions and 6 deletions

View file

@ -1,11 +1,19 @@
const fs = require('fs');
const path = require('path');
const del = require('del');
const prettier = require('prettier');
const chalk = require('chalk');
const src = path.resolve(__dirname, '../lang');
const dest = path.resolve(__dirname, '../build');
const files = fs.readdirSync(src);
const removed = del.sync([path.join(dest, '*.json')]);
if (removed.length) {
console.log(removed.map(n => `${n} ${chalk.redBright('✗')}`).join('\n'));
}
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
}
@ -23,5 +31,5 @@ files.forEach(file => {
fs.writeFileSync(path.resolve(dest, file), json);
console.log(path.resolve(src, file), '->', path.resolve(dest, file));
console.log(path.resolve(src, file), chalk.greenBright('->'), path.resolve(dest, file));
});