mirror of
https://github.com/renovatebot/renovate.git
synced 2025-01-12 06:56:24 +00:00
feat: discard npmrc if containing variables
.npmrc files will fail during lock file generation if they contain unexpanded variables, so it’s better to discard them instead.
This commit is contained in:
parent
2b2b1d92ab
commit
1352bbeb18
2 changed files with 24 additions and 1 deletions
|
@ -58,7 +58,15 @@ async function extractDependencies(content, packageFile, config) {
|
|||
npmrc = await platform.getFile(
|
||||
upath.join(path.dirname(packageFile), '.npmrc')
|
||||
);
|
||||
if (!npmrc) {
|
||||
if (npmrc) {
|
||||
if (
|
||||
npmrc.includes('=${') &&
|
||||
!(config.global && config.global.exposeEnv)
|
||||
) {
|
||||
logger.info('Discarding .npmrc file with variables');
|
||||
npmrc = undefined;
|
||||
}
|
||||
} else {
|
||||
npmrc = undefined;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -75,6 +75,21 @@ describe('manager/npm/extract', () => {
|
|||
);
|
||||
expect(res).toMatchSnapshot();
|
||||
});
|
||||
it('finds and discards .npmrc', async () => {
|
||||
platform.getFile = jest.fn(fileName => {
|
||||
if (fileName === '.npmrc') {
|
||||
// eslint-disable-next-line
|
||||
return '//registry.npmjs.org/:_authToken=${NPM_AUTH_TOKEN}\n';
|
||||
}
|
||||
return null;
|
||||
});
|
||||
const res = await npmExtract.extractDependencies(
|
||||
input01Content,
|
||||
'package.json',
|
||||
{ global: {} }
|
||||
);
|
||||
expect(res.npmrc).toBeUndefined();
|
||||
});
|
||||
it('finds lerna', async () => {
|
||||
platform.getFile = jest.fn(fileName => {
|
||||
if (fileName === 'lerna.json') {
|
||||
|
|
Loading…
Reference in a new issue