mirror of
https://github.com/pnpm/pnpm.git
synced 2026-04-12 02:57:44 -04:00
feat(reporting): an option to hide directory location
This commit is contained in:
5
.changeset/angry-eagles-breathe.md
Normal file
5
.changeset/angry-eagles-breathe.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/default-reporter": minor
|
||||
---
|
||||
|
||||
Add an option to hide the directory prefix in the progress output.
|
||||
@@ -25,6 +25,7 @@ export function initDefaultReporter (
|
||||
throttleProgress?: number
|
||||
outputMaxWidth?: number
|
||||
hideAddedPkgsProgress?: boolean
|
||||
hideProgressPrefix?: boolean
|
||||
}
|
||||
context: {
|
||||
argv: string[]
|
||||
@@ -105,6 +106,7 @@ export function toOutput$ (
|
||||
aggregateOutput?: boolean
|
||||
throttleProgress?: number
|
||||
hideAddedPkgsProgress?: boolean
|
||||
hideProgressPrefix?: boolean
|
||||
}
|
||||
context: {
|
||||
argv: string[]
|
||||
@@ -262,6 +264,7 @@ export function toOutput$ (
|
||||
throttleProgress: opts.reportingOptions?.throttleProgress,
|
||||
width: opts.reportingOptions?.outputMaxWidth,
|
||||
hideAddedPkgsProgress: opts.reportingOptions?.hideAddedPkgsProgress,
|
||||
hideProgressPrefix: opts.reportingOptions?.hideProgressPrefix,
|
||||
}
|
||||
)
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ export function reporterForClient (
|
||||
throttleProgress?: number
|
||||
width?: number
|
||||
hideAddedPkgsProgress?: boolean
|
||||
hideProgressPrefix?: boolean
|
||||
}
|
||||
): Array<Rx.Observable<Rx.Observable<{ msg: string }>>> {
|
||||
const width = opts.width ?? process.stdout.columns ?? 80
|
||||
@@ -124,6 +125,7 @@ export function reporterForClient (
|
||||
cwd,
|
||||
throttle,
|
||||
hideAddedPkgsProgress: opts.hideAddedPkgsProgress,
|
||||
hideProgressPrefix: opts.hideProgressPrefix,
|
||||
}),
|
||||
...reportStats(log$, {
|
||||
cmd: opts.cmd,
|
||||
|
||||
@@ -27,24 +27,27 @@ export function reportProgress (
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
throttle?: Rx.OperatorFunction<any, any>
|
||||
hideAddedPkgsProgress?: boolean
|
||||
hideProgressPrefix?: boolean
|
||||
}
|
||||
) {
|
||||
const progressOutput = throttledProgressOutput.bind(null, opts)
|
||||
|
||||
return getModulesInstallProgress$(log$.stage, log$.progress).pipe(
|
||||
map(({ importingDone$, progress$, requirer }) => {
|
||||
const output$ = progressOutput(importingDone$, progress$)
|
||||
map(opts.hideProgressPrefix
|
||||
? ({ importingDone$, progress$ }) => progressOutput(importingDone$, progress$)
|
||||
: ({ importingDone$, progress$, requirer }) => {
|
||||
const output$ = progressOutput(importingDone$, progress$)
|
||||
|
||||
if (requirer === opts.cwd) {
|
||||
return output$
|
||||
}
|
||||
return output$.pipe(
|
||||
map((msg: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
msg['msg'] = zoomOut(opts.cwd, requirer, msg['msg'])
|
||||
return msg
|
||||
})
|
||||
)
|
||||
})
|
||||
if (requirer === opts.cwd) {
|
||||
return output$
|
||||
}
|
||||
return output$.pipe(
|
||||
map((msg: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
|
||||
msg['msg'] = zoomOut(opts.cwd, requirer, msg['msg'])
|
||||
return msg
|
||||
})
|
||||
)
|
||||
})
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -159,6 +159,39 @@ test('prints progress beginning of node_modules from not cwd', (done) => {
|
||||
})
|
||||
})
|
||||
|
||||
test('prints progress beginning of node_modules from not cwd, when progress prefix is hidden', (done) => {
|
||||
const output$ = toOutput$({
|
||||
context: {
|
||||
argv: ['install'],
|
||||
config: { dir: '/src/projects' } as Config,
|
||||
},
|
||||
streamParser: createStreamParser(),
|
||||
reportingOptions: {
|
||||
hideProgressPrefix: true,
|
||||
},
|
||||
})
|
||||
|
||||
stageLogger.debug({
|
||||
prefix: '/src/projects/foo',
|
||||
stage: 'resolution_started',
|
||||
})
|
||||
progressLogger.debug({
|
||||
packageId: 'registry.npmjs.org/foo/1.0.0',
|
||||
requester: '/src/projects/foo',
|
||||
status: 'resolved',
|
||||
})
|
||||
|
||||
expect.assertions(1)
|
||||
|
||||
output$.pipe(take(1)).subscribe({
|
||||
complete: () => done(),
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`Progress: resolved ${hlValue('1')}, reused ${hlValue('0')}, downloaded ${hlValue('0')}, added ${hlValue('0')}`)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('prints progress beginning when appendOnly is true', (done) => {
|
||||
const output$ = toOutput$({
|
||||
context: {
|
||||
|
||||
Reference in New Issue
Block a user