Skip to content

Commit

Permalink
fix(npm): don’t strip every npmrc line containing variables
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Mar 27, 2021
1 parent 66c3b1c commit dd8c39a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion lib/manager/npm/extract/index.spec.ts
Expand Up @@ -125,7 +125,7 @@ describe('manager/npm/extract', () => {
'package.json',
{}
);
expect(res.npmrc).toBeUndefined();
expect(res.npmrc).toEqual('');
});
it('finds lerna', async () => {
fs.readLocalFile = jest.fn((fileName) => {
Expand Down
12 changes: 8 additions & 4 deletions lib/manager/npm/extract/index.ts
Expand Up @@ -111,10 +111,14 @@ export async function extractPackageFile(
npmrc = npmrc.replace(/(^|\n)package-lock.*?(\n|$)/g, '\n');
}
if (npmrc.includes('=${') && getAdminConfig().trustLevel !== 'high') {
logger.debug('Discarding .npmrc file with variables');
ignoreNpmrcFile = true;
npmrc = undefined;
await deleteLocalFile(npmrcFileName);
logger.debug(
{ npmrcFileName },
'Discarding .npmrc lines with variables'
);
npmrc = npmrc
.split('\n')
.filter((line) => !line.includes('=${'))
.join('\n');
}
} else {
npmrc = undefined;
Expand Down

0 comments on commit dd8c39a

Please sign in to comment.