-
Notifications
You must be signed in to change notification settings - Fork 673
/
.pnpmfile.cjs
45 lines (38 loc) · 961 Bytes
/
.pnpmfile.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
const PACKAGES_WITH_ENFORCED_SINGLE_VERSION = ['@emotion/react']
/**
* @author remorses
* @see https://github.com/pnpm/pnpm/issues/2713#issuecomment-1141000426
*/
function afterAllResolved(lockfile, context) {
context.log('Checking duplicate packages...')
const packagesKeys = Object.keys(lockfile.packages)
const found = {}
for (let p of packagesKeys) {
for (let x of PACKAGES_WITH_ENFORCED_SINGLE_VERSION) {
if (p.startsWith(`/${x}/`)) {
if (found[x]) {
found[x].push(p)
} else {
found[x] = [p]
}
}
}
}
let msg = ''
for (let p in found) {
const count = found[p].length
if (count > 1) {
msg +=
`${p} found ${count} times\n` +
found[p].map((s) => `- ${s}`).join('\n') +
'\n\n'
}
}
if (msg) console.warn('\n\n\n🔥\n', '🔥', msg, '\n🔥\n\n\n')
return lockfile
}
module.exports = {
hooks: {
afterAllResolved,
},
}