Skip to content

Commit

Permalink
fix: check for .yarnrc.yml first before .yarnrc
Browse files Browse the repository at this point in the history
  • Loading branch information
ylemkimon committed Sep 9, 2020
1 parent 15f6f02 commit 06342b6
Showing 1 changed file with 15 additions and 13 deletions.
28 changes: 15 additions & 13 deletions lib/manager/npm/post-update/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,23 @@ async function updateYarnOffline(
): Promise<void> {
try {
const resolvedPaths: string[] = [];
const yarnrc = await getFile(upath.join(lockFileDir, '.yarnrc'));
const yarnrcYml = await getFile(upath.join(lockFileDir, '.yarnrc.yml'));
const yarnrc = await getFile(upath.join(lockFileDir, '.yarnrc'));

if (yarnrc) {
// As .yarnrc.yml overrides .yarnrc in Yarn 1 (https://git.io/JUcco)
// both files may exist, so check for .yarnrc.yml first
if (yarnrcYml) {
// Yarn 2 (offline cache and zero-installs)
const config = parseSyml(yarnrcYml);
resolvedPaths.push(
upath.join(lockFileDir, config.cacheFolder || './.yarn/cache')
);

resolvedPaths.push(upath.join(lockFileDir, '.pnp'));
if (config.pnpDataPath) {
resolvedPaths.push(upath.join(lockFileDir, config.pnpDataPath));
}
} else if (yarnrc) {
// Yarn 1 (offline mirror)
const mirrorLine = yarnrc
.split('\n')
Expand All @@ -360,17 +373,6 @@ async function updateYarnOffline(
.replace(/\/?$/, '/');
resolvedPaths.push(upath.join(lockFileDir, mirrorPath));
}
} else if (yarnrcYml) {
// Yarn 2 (offline cache and zero-installs)
const config = parseSyml(yarnrcYml);
resolvedPaths.push(
upath.join(lockFileDir, config.cacheFolder || './.yarn/cache')
);

resolvedPaths.push(upath.join(lockFileDir, '.pnp'));
if (config.pnpDataPath) {
resolvedPaths.push(upath.join(lockFileDir, config.pnpDataPath));
}
}
logger.debug({ resolvedPaths }, 'updateYarnOffline resolvedPaths');

Expand Down

0 comments on commit 06342b6

Please sign in to comment.