From 20542e752946619f73448c56b41382a2a953f104 Mon Sep 17 00:00:00 2001
From: Rhys Arkins <rhys@keylocation.sg>
Date: Thu, 14 Sep 2017 22:10:51 +0200
Subject: [PATCH] fix: write only updated package.json files when checking for
 lock files (#810)

---
 lib/workers/branch/lock-files.js       |  3 +++
 test/workers/branch/lock-files.spec.js | 10 ++++++++++
 2 files changed, 13 insertions(+)

diff --git a/lib/workers/branch/lock-files.js b/lib/workers/branch/lock-files.js
index f6f74a95d4..af518832ab 100644
--- a/lib/workers/branch/lock-files.js
+++ b/lib/workers/branch/lock-files.js
@@ -137,6 +137,9 @@ async function writeUpdatedPackageFiles(config) {
     return;
   }
   for (const packageFile of config.updatedPackageFiles) {
+    if (!packageFile.name.endsWith('package.json')) {
+      continue; // eslint-disable-line
+    }
     logger.debug(`Writing ${packageFile.name}`);
     const massagedFile = JSON.parse(packageFile.contents);
     if (massagedFile.name && !massagedFile.name.match(/^[0-9a-z-_]+$/)) {
diff --git a/test/workers/branch/lock-files.spec.js b/test/workers/branch/lock-files.spec.js
index c0ab1c68dc..0281c6c54b 100644
--- a/test/workers/branch/lock-files.spec.js
+++ b/test/workers/branch/lock-files.spec.js
@@ -226,6 +226,16 @@ describe('workers/branch/lock-files', () => {
       await writeUpdatedPackageFiles(config);
       expect(fs.outputFile.mock.calls).toHaveLength(0);
     });
+    it('returns if no updated packageFiles are package.json', async () => {
+      config.updatedPackageFiles = [
+        {
+          name: 'Dockerfile',
+          contents: 'some-contents',
+        },
+      ];
+      await writeUpdatedPackageFiles(config);
+      expect(fs.outputFile.mock.calls).toHaveLength(0);
+    });
     it('writes updated packageFiles', async () => {
       config.updatedPackageFiles = [
         {
-- 
GitLab