Added telemetry script.

This commit is contained in:
Mike Cao 2022-03-16 21:50:24 -07:00
parent 3717b0e888
commit 45e4bfe3a9
6 changed files with 162 additions and 31 deletions

View file

@ -1,4 +1,4 @@
const fs = require('fs');
const fs = require('fs-extra');
const path = require('path');
const del = require('del');
const prettier = require('prettier');
@ -14,22 +14,24 @@ if (removed.length) {
console.log(removed.map(n => `${n} ${chalk.redBright('✗')}`).join('\n'));
}
if (!fs.existsSync(dest)) {
fs.mkdirSync(dest);
async function run() {
await fs.ensureDir(dest);
files.forEach(file => {
const lang = require(`../lang/${file}`);
const keys = Object.keys(lang).sort();
const formatted = keys.reduce((obj, key) => {
obj[key] = { defaultMessage: lang[key] };
return obj;
}, {});
const json = prettier.format(JSON.stringify(formatted), { parser: 'json' });
fs.writeFileSync(path.resolve(dest, file), json);
console.log(path.resolve(src, file), chalk.greenBright('->'), path.resolve(dest, file));
});
}
files.forEach(file => {
const lang = require(`../lang/${file}`);
const keys = Object.keys(lang).sort();
const formatted = keys.reduce((obj, key) => {
obj[key] = { defaultMessage: lang[key] };
return obj;
}, {});
const json = prettier.format(JSON.stringify(formatted), { parser: 'json' });
fs.writeFileSync(path.resolve(dest, file), json);
console.log(path.resolve(src, file), chalk.greenBright('->'), path.resolve(dest, file));
});
run();