diff --git a/lib/manager/npm/post-update/index.js b/lib/manager/npm/post-update/index.js index 88a02e84cbd7d9338483d6096f08d8c72588451f..18dded9effa1ca99ea951d652dc38af4ee34edfb 100644 --- a/lib/manager/npm/post-update/index.js +++ b/lib/manager/npm/post-update/index.js @@ -184,7 +184,7 @@ async function writeExistingFiles(config, packageFiles) { if (npmLock) { const npmLockPath = upath.join(config.tmpDir.path, npmLock); if (config.type === 'lockFileMaintenance') { - logger.trace(`Removing ${npmLock}`); + logger.debug(`Ensuring ${npmLock} is removed`); await fs.remove(npmLockPath); } else { logger.debug(`Writing ${npmLock}`); @@ -192,16 +192,17 @@ async function writeExistingFiles(config, packageFiles) { await fs.outputFile(npmLockPath, existingNpmLock); } } - if (packageFile.yarnLock && config.type !== 'lockFileMaintenance') { - logger.debug(`Writing yarn.lock to ${basedir}`); - const yarnLock = await platform.getFile(packageFile.yarnLock); - await fs.outputFile( - upath.join(config.tmpDir.path, packageFile.yarnLock), - yarnLock - ); - } else { - logger.trace(`Removing ${basedir}/yarn.lock`); - await fs.remove(upath.join(basedir, 'yarn.lock')); + const { yarnLock } = packageFile; + if (yarnLock) { + const yarnLockPath = upath.join(config.tmpDir.path, yarnLock); + if (config.type === 'lockFileMaintenance') { + logger.debug(`Ensuring ${yarnLock} is removed`); + await fs.remove(yarnLockPath); + } else { + logger.debug(`Writing ${yarnLock}`); + const existingYarnLock = await platform.getFile(yarnLock); + await fs.outputFile(yarnLockPath, existingYarnLock); + } } // TODO: Update the below with this once https://github.com/pnpm/pnpm/issues/992 is fixed const pnpmBug992 = true;