-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathminify.js
34 lines (24 loc) · 864 Bytes
/
minify.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
const fs = require('fs');
var path = require('path')
const rootFolder = './abi/';
const dir={
js:rootFolder+'js/',
json:rootFolder+'json/'
}
fs.readdirSync(dir.json).forEach(folder => {
fs.readdirSync(path.join(dir.json ,folder)).forEach(file => {
if (path.extname(file) === '.json') {
const content = fs.readFileSync(path.join(__dirname, dir.json , folder , file) );
const minified = JSON.stringify(JSON.parse(content));
// Write jsFile
const jsfileName = file.substr(0, file.lastIndexOf(".")) + ".js";
const jsContent="module.exports = " + minified;
const outFolder = path.join(__dirname, dir.js , folder)
if (!fs.existsSync(outFolder)) {
fs.mkdirSync(outFolder);
}
fs.writeFileSync(path.join(outFolder , jsfileName), jsContent);
}
})
});
console.log("FINISHED MINI-FYING")