Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for process.env.npminstall_cache #471

Merged
merged 1 commit into from
Dec 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions bin/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,9 @@ if (production) {
if (cacheDir === null && process.env.npm_config_cache) {
cacheDir = process.env.npm_config_cache;
}
if (process.env.npminstall_cache) {
cacheDir = process.env.npminstall_cache;
}

let forbiddenLicenses = argv['forbidden-licenses'];
forbiddenLicenses = forbiddenLicenses ? forbiddenLicenses.split(',') : null;
Expand Down
13 changes: 13 additions & 0 deletions test/install-cache-strict.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,17 @@ describe('test/install-cache-strict.test.js', () => {
.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')));
});
});
Loading