/
install-cache-strict.test.js
88 lines (79 loc) · 2.62 KB
/
install-cache-strict.test.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
const assert = require('node:assert');
const path = require('node:path');
const fs = require('node:fs/promises');
const coffee = require('coffee');
const helper = require('./helper');
describe('test/install-cache-strict.test.js', () => {
// Fixme: mock Windows homedir
if (process.platform === 'win32') return;
const [ homedir, cleanupTmp ] = helper.tmp();
const demo = helper.fixtures('demo-install-cache-strict');
const cleanupModules = helper.cleanup(demo);
async function cleanup() {
await cleanupModules();
await cleanupTmp();
}
beforeEach(cleanup);
afterEach(cleanup);
it('should read disk cache on --cache-strict --production', async () => {
await coffee.fork(helper.npminstall, [ '--cache-strict', '--production' ], {
cwd: demo,
env: Object.assign({}, process.env, {
HOME: homedir,
npm_config_cache: '',
}),
})
.debug()
.end();
assert(await fs.stat(path.join(homedir, '.npminstall_tarball/d/e/b/u/debug')));
});
it('should read disk cache on --cache-strict', async () => {
await coffee.fork(helper.npminstall, [ '--cache-strict' ], {
cwd: demo,
env: Object.assign({}, process.env, {
HOME: homedir,
npm_config_cache: '',
}),
})
.debug()
.end();
assert(await fs.stat(path.join(homedir, '.npminstall_tarball/d/e/b/u/debug')));
});
it('should read disk cache from npm_config_cache env', async () => {
await coffee.fork(helper.npminstall, [], {
cwd: demo,
env: Object.assign({}, process.env, {
HOME: homedir,
npm_config_cache: path.join(homedir, 'foocache/.npminstall_tarball'),
}),
})
.debug()
.end();
assert(await fs.stat(path.join(homedir, 'foocache/.npminstall_tarball/d/e/b/u/debug')));
});
it('should read disk cache on --cache-strict NODE_ENV=production', async () => {
await coffee.fork(helper.npminstall, [ '--cache-strict' ], {
cwd: demo,
env: Object.assign({}, process.env, {
HOME: homedir,
NODE_ENV: 'production',
npm_config_cache: '',
}),
})
.debug()
.end();
assert(await fs.stat(path.join(homedir, '.npminstall_tarball/d/e/b/u/debug')));
});
it('should read disk cache from npminstall_cache env', async () => {
await coffee.fork(helper.npminstall, [], {
cwd: demo,
env: Object.assign({}, process.env, {
HOME: homedir,
npminstall_cache: path.join(homedir, 'foocache/.npminstall_tarball'),
}),
})
.debug()
.end();
assert(await fs.stat(path.join(homedir, 'foocache/.npminstall_tarball/d/e/b/u/debug')));
});
});