/
reportContext.ts
48 lines (47 loc) · 1.34 KB
/
reportContext.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
import path from 'path'
import { type ContextLog, type PackageImportMethodLog } from '@pnpm/core-loggers'
import * as Rx from 'rxjs'
import { map, take } from 'rxjs/operators'
import normalize from 'normalize-path'
export function reportContext (
log$: {
context: Rx.Observable<ContextLog>
packageImportMethod: Rx.Observable<PackageImportMethodLog>
},
opts: { cwd: string }
) {
return Rx.combineLatest(
log$.context.pipe(take(1)),
log$.packageImportMethod.pipe(take(1))
)
.pipe(
map(
([context, packageImportMethod]) => {
if (context.currentLockfileExists) {
return Rx.NEVER
}
let method!: string
switch (packageImportMethod.method) {
case 'copy':
method = 'copied'
break
case 'clone':
method = 'cloned'
break
case 'hardlink':
method = 'hard linked'
break
default:
method = packageImportMethod.method
break
}
return Rx.of({
msg: `\
Packages are ${method} from the content-addressable store to the virtual store.
Content-addressable store is at: ${context.storeDir}
Virtual store is at: ${normalize(path.relative(opts.cwd, context.virtualStoreDir))}`,
})
}
)
)
}