Skip to content

Commit

Permalink
fix: Run dedupe during upgrade on yarn 3 (#5458)
Browse files Browse the repository at this point in the history
Co-authored-by: Dominic Saadi <32992335+jtoar@users.noreply.github.com>
  • Loading branch information
callingmedic911 and jtoar authored May 9, 2022
1 parent 39dfc31 commit 905b999
Showing 1 changed file with 12 additions and 7 deletions.
19 changes: 12 additions & 7 deletions packages/cli/src/commands/upgrade.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,24 +278,29 @@ const dedupeDeps = async (task, { verbose }) => {
try {
const yarnVersion = await getCmdMajorVersion('yarn')
const npxVersion = await getCmdMajorVersion('npx')
if (yarnVersion > 1) {
task.skip('Deduplication is only required for <=1.x')
return
}
let npxArgs = []
if (npxVersion > 6) {
npxArgs = ['--yes']
}

await execa('npx', [...npxArgs, 'yarn-deduplicate'], {
const baseExecaArgsForDedupe = {
shell: true,
stdio: verbose ? 'inherit' : 'pipe',
cwd: getPaths().base,
})
}
if (yarnVersion > 1) {
await execa('yarn', ['dedupe'], baseExecaArgsForDedupe)
} else {
await execa(
'npx',
[...npxArgs, 'yarn-deduplicate'],
baseExecaArgsForDedupe
)
}
} catch (e) {
console.log(c.error(e.message))
throw new Error(
'Could not finish deduplication. If the project is using yarn 1.x, please run `npx yarn-deduplicate`, before continuing'
'Could not finish de-duplication. For yarn 1.x, please run `npx yarn-deduplicate`, or for yarn 3 run `yarn dedupe` before continuing'
)
}
await yarnInstall({ verbose })
Expand Down

0 comments on commit 905b999

Please sign in to comment.