-
Notifications
You must be signed in to change notification settings - Fork 0
/
minimize.js
66 lines (56 loc) · 2.19 KB
/
minimize.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
const fs = require('fs');
var luamin = require('luamin');
function logic() {
console.log("Creating directories...");
fs.mkdirSync('./dist');
fs.mkdirSync('./dist/stats');
fs.mkdirSync('./dist/stats/scripts');
fs.mkdirSync('./dist/stats/scripts/stats');
fs.mkdirSync('./dist/stats/ui_scripts');
fs.mkdirSync('./dist/stats/ui_scripts/stats');
fs.mkdirSync('./dist/stats/ui_scripts/stats/common');
fs.mkdirSync('./dist/stats/ui_scripts/stats/menus');
fs.readdir('./scripts/stats/', (err, files) => {
files.forEach(file => {
const buffer = fs.readFileSync('./scripts/stats/' + file);
const fileContent = buffer.toString();
var test = luamin.minify(fileContent);
fs.writeFile('./dist/stats/scripts/stats/' + file, test, function() {})
});
});
const buffer = fs.readFileSync('./ui_scripts/stats/' + '__init__.lua');
const fileContent = buffer.toString();
var test = luamin.minify(fileContent);
fs.writeFile('./dist/stats/ui_scripts/stats/' + '__init__.lua', test, function() {})
fs.readdir('./ui_scripts/stats/common/', (err, files) => {
files.forEach(file => {
const buffer = fs.readFileSync('./ui_scripts/stats/common/' + file);
const fileContent = buffer.toString();
var test = luamin.minify(fileContent);
fs.writeFile('./dist/stats/ui_scripts/stats/common/' + file, test, function() {})
});
});
fs.readdir('./ui_scripts/stats/menus/', (err, files) => {
files.forEach(file => {
const buffer = fs.readFileSync('./ui_scripts/stats/menus/' + file);
const fileContent = buffer.toString();
var test = luamin.minify(fileContent);
fs.writeFile('./dist/stats/ui_scripts/stats/menus/' + file, test, function() {})
});
});
fs.copyFile('info.json', './dist/stats/info.json', (err) => {
if (err) throw err;
});
console.log("Job finished.");
}
if (fs.existsSync('./dist')) {
fs.rm('./dist', { recursive: true }, (err) => {
if (err) {
console.log(err);
throw err;
}
logic();
});
} else {
logic();
}