Skip to content

Commit

Permalink
fix(cli): run yarn install after fixing yarn.lock by deduplicating (#676
Browse files Browse the repository at this point in the history
)
  • Loading branch information
mediremi committed Oct 13, 2021
1 parent 88be6eb commit a32f969
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cli/src/commands/deduplicate.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ const handler = async ({ cwd }) => {
const deduped = fixDuplicates(yarnLock)
fs.writeFileSync(paths.yarnLock, deduped)

if (deduped !== yarnLock) {
reporter.info(
`Run ${chalk.bold('yarn install')} to deduplicate node_modules`
)
}

const duplicates = listDuplicates(deduped)
if (duplicates.size > 0) {
reporter.error('Failed to deduplicate the following packages:')
Expand Down
7 changes: 6 additions & 1 deletion cli/src/lib/validators/validateLockfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const fs = require('fs')
const { reporter, prompt } = require('@dhis2/cli-helpers-engine')
const { reporter, prompt, exec } = require('@dhis2/cli-helpers-engine')
const { listDuplicates, fixDuplicates } = require('../yarnDeduplicate')

const singletonDependencies = [
Expand Down Expand Up @@ -52,6 +52,11 @@ exports.validateLockfile = async (pkg, { paths, offerFix = false }) => {
}
const dedupedYarnLock = fixDuplicates(yarnLock)
fs.writeFileSync(paths.yarnLock, dedupedYarnLock)
await exec({
cmd: 'yarn',
args: ['install'],
cwd: paths.base,
})
return listSingletonDuplicates(dedupedYarnLock).size === 0
}

Expand Down

0 comments on commit a32f969

Please sign in to comment.