[Scripts > Strip] Strip JSON files, clean up code

main
CanadaHonk 2 years ago committed by GitHub
parent fd5b7ba4ca
commit d3a586c892
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -28,14 +28,23 @@ const stripCode = (code) => code
.replaceAll('#', ' ')
.replaceAll('? ?', '??');
const stripFile = (jsPath) => {
console.log(jsPath);
fs.writeFileSync(jsPath, stripCode(fs.readFileSync(jsPath, 'utf8')));
const stripJs = (jsPath) => fs.writeFileSync(jsPath, stripCode(fs.readFileSync(jsPath, 'utf8')));
const minJson = (data) => {
if (data.description) delete data.description;
return data;
};
const stripJson = (path) => fs.writeFileSync(path, JSON.stringify(minJson(JSON.parse(fs.readFileSync(path, 'utf8')))));
const tree = (dirPath) => fs.readdirSync(dirPath).forEach((x) => {
if (x.endsWith('.js')) return stripFile(join(dirPath, x));
if (!x.includes('.')) return tree(join(dirPath, x));
const path = join(dirPath, x);
console.log(path);
if (x.endsWith('.js')) return stripJs(path);
if (x.endsWith('.json')) return stripJson(path);
if (!x.includes('.')) return tree(path);
});
tree(join(__dirname, '..', 'src'));
Loading…
Cancel
Save