/
pnpm.ts
72 lines (68 loc) · 1.46 KB
/
pnpm.ts
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
'use strict'
// Avoid "Possible EventEmitter memory leak detected" warnings
// because it breaks pnpm's CLI output
process.setMaxListeners(0)
const argv = process.argv.slice(2)
// eslint-disable-next-line @typescript-eslint/no-floating-promises
; (async () => {
switch (argv[0]) {
case '-v':
case '--version': {
const { version } = (await import('@pnpm/cli-meta')).packageManager
console.log(version)
break
}
// commands that are passed through to npm:
case 'access':
case 'adduser':
case 'bugs':
case 'deprecate':
case 'dist-tag':
case 'docs':
case 'edit':
case 'info':
case 'login':
case 'logout':
case 'owner':
case 'ping':
case 'prefix':
case 'profile':
case 'pkg':
case 'repo':
case 's':
case 'se':
case 'search':
case 'set-script':
case 'show':
case 'star':
case 'stars':
case 'team':
case 'token':
case 'unpublish':
case 'unstar':
case 'v':
case 'version':
case 'view':
case 'whoami':
case 'xmas':
await passThruToNpm()
break
default:
await runPnpm()
break
}
})()
async function runPnpm (): Promise<void> {
const { errorHandler } = await import('./errorHandler')
try {
const { main } = await import('./main')
await main(argv)
} catch (err: any) { // eslint-disable-line
await errorHandler(err)
}
}
async function passThruToNpm (): Promise<void> {
const { runNpm } = await import('./runNpm')
const { status } = await runNpm(argv)
process.exit(status!)
}