-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathprepareResults.mjs
More file actions
52 lines (39 loc) · 1.32 KB
/
prepareResults.mjs
File metadata and controls
52 lines (39 loc) · 1.32 KB
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
// Script to make the benchmark result files accessible to the benchmark viewer app
//
// - keeps them at their current place for easier access tp benchmark
// history data in the future
// - maybe preprocess and combine them into 1 single file?
import * as fs from 'fs';
import * as path from 'path';
function copyFileSync(src, dest) {
console.log('copying', src, 'to', dest);
fs.copyFileSync(src, dest);
}
/* benchmark results */
// older benchmark app builds where based on publishing the whole
// docs folder with github pages
const sourceDir = 'results';
// everything in public can be fetched from the app
const destDir = 'public/results';
if (!fs.existsSync(sourceDir)) {
console.error('does not exist:', sourceDir);
process.exit(1);
}
if (!fs.existsSync(destDir)) {
fs.mkdirSync(destDir, { recursive: true });
}
const files = fs.readdirSync(sourceDir);
files.forEach(file => {
const sourcePath = path.join(sourceDir, file);
const destPath = path.join(destDir, file);
const stats = fs.statSync(sourcePath);
if (stats.isDirectory()) {
console.error('did not expect a directory here:', destPath);
process.exit(1);
}
copyFileSync(sourcePath, destPath);
});
/* package popularity file */
copyFileSync('packagesPopularity.json', 'public/packagesPopularity.json');
console.log('done');
process.exit(0);