From 16f6b5810ac6a5e2f2464b303114beea9a851f3d Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@arkins.net>
Date: Fri, 11 May 2018 07:23:26 +0200
Subject: [PATCH] fix(npm): skip lock file check if no npm package files

---
 lib/manager/npm/post-update/index.js         | 5 ++++-
 test/workers/branch/lock-files/index.spec.js | 4 ++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/lib/manager/npm/post-update/index.js b/lib/manager/npm/post-update/index.js
index fc205791f0..b4f8395e5d 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 5cca0fad0c..d313808d69 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);
-- 
GitLab