diff --git a/lib/manager/npm/post-update/index.js b/lib/manager/npm/post-update/index.js index 99efe639877b3fb8e822f2a3f489fe0f83ebc6a5..89c2d7e72c8b26ae01bc50f638848e3bce701c70 100644 --- a/lib/manager/npm/post-update/index.js +++ b/lib/manager/npm/post-update/index.js @@ -112,6 +112,7 @@ async function writeExistingFiles(config, packageFiles) { { packageFiles: npmFiles.map(n => n.packageFile) }, 'Writing package.json files' ); + const writtenLockFiles = []; for (const packageFile of npmFiles) { const basedir = upath.join( config.localDir, @@ -225,10 +226,11 @@ async function writeExistingFiles(config, packageFiles) { if (config.reuseLockFiles === false) { logger.debug(`Ensuring ${yarnLock} is removed`); await fs.remove(yarnLockPath); - } else { + } else if (!writtenLockFiles[yarnLock]) { logger.debug(`Writing ${yarnLock}`); const existingYarnLock = await platform.getFile(yarnLock); await fs.outputFile(yarnLockPath, existingYarnLock); + writtenLockFiles[yarnLock] = true; } } // TODO: Update the below with this once https://github.com/pnpm/pnpm/issues/992 is fixed