Skip to content

Commit

Permalink
refactor(npm): yarn dedupe postUpdateOptions (#11148)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Kriese <michael.kriese@visualon.de>
  • Loading branch information
ylemkimon and viceice committed Aug 9, 2021
1 parent 5b38392 commit cf3f74f
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions lib/manager/npm/post-update/yarn.ts
Expand Up @@ -147,25 +147,24 @@ export async function generateLockFile(
}

// postUpdateOptions
if (isYarn1 && config.postUpdateOptions?.includes('yarnDedupeFewer')) {
logger.debug('Performing yarn dedupe fewer');
commands.push('npx yarn-deduplicate --strategy fewer');
// Run yarn again in case any changes are necessary
commands.push(`yarn install ${cmdOptions}`.trim());
}
if (
(isYarn1 || isYarnDedupeAvailable) &&
config.postUpdateOptions?.includes('yarnDedupeHighest')
) {
logger.debug('Performing yarn dedupe highest');
if (isYarn1) {
commands.push('npx yarn-deduplicate --strategy highest');
// Run yarn again in case any changes are necessary
commands.push(`yarn install ${cmdOptions}`.trim());
} else {
commands.push('yarn dedupe --strategy highest');
['fewer', 'highest'].forEach((s) => {
if (
config.postUpdateOptions?.includes(
`yarnDedupe${s.charAt(0).toUpperCase()}${s.slice(1)}`
)
) {
logger.debug(`Performing yarn dedupe ${s}`);
if (isYarn1) {
commands.push(`npx yarn-deduplicate --strategy ${s}`);
// Run yarn again in case any changes are necessary
commands.push(`yarn install ${cmdOptions}`.trim());
} else if (isYarnDedupeAvailable && s === 'highest') {
commands.push(`yarn dedupe --strategy ${s}`);
} else {
logger.debug(`yarn dedupe ${s} not available`);
}
}
}
});

if (upgrades.find((upgrade) => upgrade.isLockFileMaintenance)) {
logger.debug(
Expand Down

0 comments on commit cf3f74f

Please sign in to comment.