-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.js
38 lines (29 loc) · 1.11 KB
/
run.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
const fs = require('fs');
const path = require('path');
const runBenchmarks = require('./index.js');
const { results, errors } = runBenchmarks();
const atomizedFolder = path.resolve(__dirname, 'atomized');
if (!fs.existsSync(atomizedFolder)) {
fs.mkdirSync(atomizedFolder);
}
const cleaned = results.map(function (result) {
const output = { ...result };
if (typeof(result.inputBytes) === 'number') {
output.inputBytes = result.inputBytes.toLocaleString();
}
if (typeof(result.atomizedBytes) === 'number') {
output.atomizedBytes = result.atomizedBytes.toLocaleString();
}
if (typeof(result.inputGzipBytes) === 'number') {
output.inputGzipBytes = result.inputGzipBytes.toLocaleString();
}
if (typeof(result.atomizedGzipBytes) === 'number') {
output.atomizedGzipBytes = result.atomizedGzipBytes.toLocaleString();
}
const atomizedFile = path.resolve(atomizedFolder, result.library + '-' + result.version + '.css');
fs.writeFileSync(atomizedFile, result.atomizedCss);
delete output.atomizedCss;
return output;
});
console.log(cleaned);
console.log(errors + ' files failed to atomize');