diff --git a/lib/manager/npm/post-update/index.js b/lib/manager/npm/post-update/index.js index 97a62370af5f0a7c1b1d5c16efdb37cd724ada50..bde075d86d35cfe56db9c3aac0b6d03da585101c 100644 --- a/lib/manager/npm/post-update/index.js +++ b/lib/manager/npm/post-update/index.js @@ -482,6 +482,45 @@ async function getAdditionalFiles(config, packageFiles) { name: lockFileName, contents: res.lockFile, }); + // istanbul ignore next + try { + const yarnrc = await platform.getFile( + upath.join(lockFileDir, '.yarnrc') + ); + if (yarnrc) { + const mirrorLine = yarnrc + .split('\n') + .find(line => line.startsWith('yarn-offline-mirror ')); + if (mirrorLine) { + const mirrorPath = mirrorLine + .split(' ')[1] + .replace(/"/g, '') + .replace(/\/?$/, '/'); + const resolvedPath = upath.join(lockFileDir, mirrorPath); + logger.info('Found yarn offline mirror: ' + resolvedPath); + const status = await platform.getRepoStatus(); + for (const f of status.modified.concat(status.not_added)) { + if (f.startsWith(resolvedPath)) { + const localModified = upath.join(config.localDir, f); + updatedArtifacts.push({ + name: f, + contents: await fs.readFile(localModified, 'utf8'), + }); + } + } + for (const f of status.deleted || []) { + if (f.startsWith(resolvedPath)) { + updatedArtifacts.push({ + name: '|delete|', + contents: f, + }); + } + } + } + } + } catch (err) { + logger.error({ err }, 'Error updating yarn offline packages'); + } } else { logger.debug("yarn.lock hasn't changed"); }