Skip to content
Snippets Groups Projects
Commit 2a0f2fbb authored by Rhys Arkins's avatar Rhys Arkins
Browse files

fix(npm): filter out package-lock = false in .npmrc

This prevents us from updating npm lock files
parent 3dffefd8
No related branches found
No related tags found
No related merge requests found
...@@ -66,6 +66,10 @@ async function extractDependencies(content, packageFile, config) { ...@@ -66,6 +66,10 @@ async function extractDependencies(content, packageFile, config) {
npmrc = await platform.getFile( npmrc = await platform.getFile(
upath.join(path.dirname(packageFile), '.npmrc') upath.join(path.dirname(packageFile), '.npmrc')
); );
if (npmrc && npmrc.includes('package-lock')) {
logger.info('Stripping package-lock setting from npmrc');
npmrc = npmrc.replace(/(^|\\n)package-lock.*?(\n|$)/g, '');
}
if (npmrc) { if (npmrc) {
if ( if (
npmrc.includes('=${') && npmrc.includes('=${') &&
......
...@@ -76,6 +76,20 @@ describe('manager/npm/extract', () => { ...@@ -76,6 +76,20 @@ describe('manager/npm/extract', () => {
); );
expect(res).toMatchSnapshot(); expect(res).toMatchSnapshot();
}); });
it('finds and filters .npmrc', async () => {
platform.getFile = jest.fn(fileName => {
if (fileName === '.npmrc') {
return 'save-exact = true\npackage-lock = false\n';
}
return null;
});
const res = await npmExtract.extractDependencies(
input01Content,
'package.json',
{ global: {} }
);
expect(res.npmrc).toBeDefined();
});
it('finds and discards .npmrc', async () => { it('finds and discards .npmrc', async () => {
platform.getFile = jest.fn(fileName => { platform.getFile = jest.fn(fileName => {
if (fileName === '.npmrc') { if (fileName === '.npmrc') {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment