/
reportInstallChecks.ts
41 lines (39 loc) · 1.02 KB
/
reportInstallChecks.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
import { type InstallCheckLog } from '@pnpm/core-loggers'
import * as Rx from 'rxjs'
import { filter, map } from 'rxjs/operators'
import { formatWarn } from './utils/formatWarn'
import { autozoom } from './utils/zooming'
export function reportInstallChecks (
installCheck$: Rx.Observable<InstallCheckLog>,
opts: {
cwd: string
}
) {
return installCheck$.pipe(
map((log) => formatInstallCheck(opts.cwd, log)),
filter(Boolean),
map((msg) => Rx.of({ msg }))
)
}
function formatInstallCheck (
currentPrefix: string,
logObj: InstallCheckLog,
opts?: {
zoomOutCurrent: boolean
}
) {
const zoomOutCurrent = opts?.zoomOutCurrent ?? false
switch (logObj.code) {
case 'EBADPLATFORM':
return autozoom(
currentPrefix,
logObj['prefix'],
formatWarn(`Unsupported system. Skipping dependency ${logObj.pkgId}`),
{ zoomOutCurrent }
)
case 'ENOTSUP':
return autozoom(currentPrefix, logObj['prefix'], logObj.toString(), { zoomOutCurrent })
default:
return undefined
}
}