-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[core] Deduplicate packages (#16608)
* [core] Deduplicate packages * Deduplicate * Move task to checkout job * Remove postinstall check, remove function wrapper
- Loading branch information
Showing
4 changed files
with
63 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* eslint-disable no-console */ | ||
|
||
const { spawn } = require('child_process'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const deduplicate = require('yarn-deduplicate'); | ||
|
||
const lockFile = path.resolve(__dirname, '../yarn.lock'); | ||
const yarnlock = fs.readFileSync(lockFile, 'utf8'); | ||
|
||
const duplicates = deduplicate.listDuplicates(yarnlock); | ||
if (duplicates.length === 0) { | ||
console.log('No duplicated packages found'); | ||
process.exit(0); | ||
} | ||
|
||
console.log( | ||
`${duplicates.length} duplicated package(s) found\n${duplicates.map(x => ` ${x}`).join('\n')}`, | ||
); | ||
|
||
if (process.env.CI) { | ||
console.error( | ||
[ | ||
`Error: There are currently ${duplicates.length} duplicated package(s).`, | ||
`To deduplicate run "yarn deduplicate"`, | ||
].join('\n'), | ||
); | ||
process.exit(1); | ||
} | ||
|
||
console.log('Deduplicating package(s)'); | ||
fs.writeFileSync(lockFile, deduplicate.fixDuplicates(yarnlock)); | ||
|
||
const yarn = spawn('yarn', { | ||
shell: true, | ||
stdio: 'inherit', | ||
cwd: path.resolve(__dirname, '..'), | ||
}); | ||
|
||
yarn.on('close', code => { | ||
process.exit(code); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters