|
| 1 | +// Script to make the benchmark result files accessible to the benchmark viewer app |
| 2 | +// |
| 3 | +// - keeps them at their current place for easier access tp benchmark |
| 4 | +// history data in the future |
| 5 | +// - maybe preprocess and combine them into 1 single file? |
| 6 | +import * as fs from 'fs'; |
| 7 | +import * as path from 'path'; |
| 8 | + |
| 9 | +function copyFileSync(src, dest) { |
| 10 | + console.log('copying', src, 'to', dest); |
| 11 | + fs.copyFileSync(src, dest); |
| 12 | +} |
| 13 | + |
| 14 | +/* benchmark results */ |
| 15 | + |
| 16 | +// older benchmark app builds where based on publishing the whole |
| 17 | +// docs folder with github pages |
| 18 | +const sourceDir = 'results'; |
| 19 | + |
| 20 | +// everything in public can be fetched from the app |
| 21 | +const destDir = 'public/results'; |
| 22 | + |
| 23 | +if (!fs.existsSync(sourceDir)) { |
| 24 | + console.error('does not exist:', sourceDir); |
| 25 | + process.exit(1); |
| 26 | +} |
| 27 | + |
| 28 | +if (!fs.existsSync(destDir)) { |
| 29 | + fs.mkdirSync(destDir, { recursive: true }); |
| 30 | +} |
| 31 | + |
| 32 | +const files = fs.readdirSync(sourceDir); |
| 33 | + |
| 34 | +files.forEach(file => { |
| 35 | + const sourcePath = path.join(sourceDir, file); |
| 36 | + const destPath = path.join(destDir, file); |
| 37 | + const stats = fs.statSync(sourcePath); |
| 38 | + |
| 39 | + if (stats.isDirectory()) { |
| 40 | + console.error('did not expect a directory here:', destPath); |
| 41 | + process.exit(1); |
| 42 | + } |
| 43 | + |
| 44 | + copyFileSync(sourcePath, destPath); |
| 45 | +}); |
| 46 | + |
| 47 | +/* package popularity file */ |
| 48 | + |
| 49 | +copyFileSync('packagesPopularity.json', 'public/packagesPopularity.json'); |
| 50 | + |
| 51 | +console.log('done'); |
| 52 | +process.exit(0); |
0 commit comments