Skip to content
Snippets Groups Projects
Unverified Commit 7fc12076 authored by Rhys Arkins's avatar Rhys Arkins Committed by GitHub
Browse files

feat(yarn): support yarn offline mirror (#4102)

Look for .yarnrc in same directory as yarn.lock. If found, look for yarn-offine-mirror line and check that folder for changes.

Closes #1452
parent 855d5fba
Branches
No related tags found
No related merge requests found
......@@ -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");
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment