diff --git a/lib/manager/npm/post-update/index.js b/lib/manager/npm/post-update/index.js index fc205791f0766391a2e599e4cb67e4b28943ac34..b4f8395e5d10fad6627988acbe4f07aa10427a4d 100644 --- a/lib/manager/npm/post-update/index.js +++ b/lib/manager/npm/post-update/index.js @@ -291,13 +291,16 @@ async function writeUpdatedPackageFiles(config) { // istanbul ignore next async function getAdditionalFiles(config, packageFiles) { logger.trace({ config }, 'getAdditionalFiles'); - logger.debug('Getting updated lock files'); const lockFileErrors = []; const updatedLockFiles = []; + if (!(packageFiles.npm && packageFiles.npm.length)) { + return { lockFileErrors, updatedLockFiles }; + } if (!config.updateLockFiles) { logger.info('Skipping lock file generation'); return { lockFileErrors, updatedLockFiles }; } + logger.debug('Getting updated lock files'); if ( config.type === 'lockFileMaintenance' && config.parentBranch && diff --git a/test/workers/branch/lock-files/index.spec.js b/test/workers/branch/lock-files/index.spec.js index 5cca0fad0cd3149cb67306559d2423741cf35ac4..d313808d69d836a0b1f5f350a951f056dde332ba 100644 --- a/test/workers/branch/lock-files/index.spec.js +++ b/test/workers/branch/lock-files/index.spec.js @@ -311,7 +311,7 @@ describe('manager/npm/post-update', () => { }); it('returns no error and empty lockfiles if updateLockFiles false', async () => { config.updateLockFiles = false; - const res = await getAdditionalFiles(config); + const res = await getAdditionalFiles(config, { npm: [{}] }); expect(res).toMatchSnapshot(); expect(res.lockFileErrors).toHaveLength(0); expect(res.updatedLockFiles).toHaveLength(0); @@ -320,7 +320,7 @@ describe('manager/npm/post-update', () => { config.type = 'lockFileMaintenance'; config.parentBranch = 'renovate/lock-file-maintenance'; platform.branchExists.mockReturnValueOnce(true); - const res = await getAdditionalFiles(config); + const res = await getAdditionalFiles(config, { npm: [{}] }); expect(res).toMatchSnapshot(); expect(res.lockFileErrors).toHaveLength(0); expect(res.updatedLockFiles).toHaveLength(0);