Co-authored-by: Ivan Akulov <mail@iamakulov.com> Co-authored-by: Satish Gandham <hello@satishgandham.com> Co-authored-by: Ivan Akulov <iamakulov@outlook.com> Co-authored-by: Aishwarya UR <aishwarya@appsmith.com> Co-authored-by: Shrikant Sharat Kandula <shrikant@appsmith.com> Co-authored-by: somangshu <somangshu.goswami1508@gmail.com>
23 lines
679 B
JavaScript
23 lines
679 B
JavaScript
module.exports = {
|
|
name: `plugin-dedupe-on-install`,
|
|
factory: (require) => {
|
|
const {execute} = require('@yarnpkg/shell')
|
|
return {
|
|
hooks: {
|
|
// yarn / yarn install / yarn add / yarn dedupe -> afterAllInstalled
|
|
async afterAllInstalled() {
|
|
// use env var to prevent infinite loops
|
|
if (!process.env.DEDUPED && !process.argv.includes('dedupe')) {
|
|
process.env.DEDUPED = 'yes'
|
|
// fast check for duplicates
|
|
if (await execute('yarn dedupe --check')) {
|
|
// run actual dedupe/link step
|
|
await execute('yarn dedupe')
|
|
}
|
|
}
|
|
},
|
|
},
|
|
}
|
|
},
|
|
}
|