forked from siddharthkp/npm-cache-benchmark
-
Notifications
You must be signed in to change notification settings - Fork 8
/
update.js
62 lines (53 loc) · 2.39 KB
/
update.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
const fs = require('fs');
const path = require('path');
const spawn = require('./src/spawn');
const dependencies = require('./benchmarks.packages.json');
updatePackageJson('npm');
spawn('rm', ['-rf', './node_cache', './node_modules', './package-lock.json'], path.resolve('npm'));
spawn('npm', ['install'], path.resolve('npm'));
spawn('rm', ['-rf', './node_cache', './node_modules'], path.resolve('npm'));
updatePackageJson('npm-offline');
spawn(
'rm',
['-rf', './node_cache', './node_modules', './package-lock.json'],
path.resolve('npm-offline')
);
spawn('npm', ['install'], path.resolve('npm-offline'));
spawn('rm', ['-rf', './node_modules'], path.resolve('npm-offline'));
updatePackageJson('pnpm');
spawn('rm', ['-rf', './.pnpm-store', './node_modules', './pnpm-lock.yaml'], path.resolve('pnpm'));
spawn('pnpm', ['install'], path.resolve('pnpm'));
spawn('rm', ['-rf', './.pnpm-store', './node_modules'], path.resolve('pnpm'));
updatePackageJson('pnpm-offline');
spawn('rm', ['-rf', './.pnpm-store', './node_modules', './pnpm-lock.yaml'], path.resolve('pnpm-offline'));
spawn('pnpm', ['install'], path.resolve('pnpm-offline'));
spawn('rm', ['-rf', './node_modules'], path.resolve('pnpm-offline'));
updatePackageJson('shrinkpack');
spawn(
'rm',
['-rf', './node_cache', './node_modules', './package-lock.json'],
path.resolve('shrinkpack')
);
spawn('npm', ['install'], path.resolve('shrinkpack'));
spawn('shrinkpack', ['.'], path.resolve('shrinkpack'));
spawn('rm', ['-rf', './node_cache', './node_modules'], path.resolve('shrinkpack'));
updatePackageJson('yarn');
spawn('rm', ['-rf', './node_cache', './node_modules', './yarn.lock'], path.resolve('yarn'));
spawn('yarn', ['install'], path.resolve('yarn'));
spawn('rm', ['-rf', './node_cache', './node_modules'], path.resolve('yarn'));
updatePackageJson('yarn-offline');
spawn('rm', ['-rf', './node_cache', './node_modules', './yarn.lock', './yarn-offline-mirror'], path.resolve('yarn-offline'));
spawn('yarn', ['install'], path.resolve('yarn-offline'));
spawn('rm', ['-rf', './node_cache', './node_modules'], path.resolve('yarn-offline'));
function updatePackageJson(directory) {
const file = path.resolve(directory, 'package.json');
const contents = prettyJson({
name: directory + '-benchmark',
version: '0.0.0',
dependencies: dependencies,
});
fs.writeFileSync(file, contents);
}
function prettyJson(data) {
return JSON.stringify(data, null, 2) + '\n';
}