mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-24 15:48:06 -05:00
fix(reporter): do not collapse warnings when append-only
This commit is contained in:
5
.changeset/fifty-ravens-obey.md
Normal file
5
.changeset/fifty-ravens-obey.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/default-reporter": patch
|
||||
---
|
||||
|
||||
Do not collapse warnings when reporting is append-only.
|
||||
@@ -73,6 +73,7 @@ export default function (
|
||||
reportMisc(
|
||||
log$,
|
||||
{
|
||||
appendOnly: opts.appendOnly === true,
|
||||
config: opts.config,
|
||||
cwd,
|
||||
logLevel: opts.logLevel,
|
||||
|
||||
@@ -25,6 +25,7 @@ export default (
|
||||
other: Rx.Observable<Log>
|
||||
},
|
||||
opts: {
|
||||
appendOnly: boolean
|
||||
cwd: string
|
||||
logLevel?: LogLevel
|
||||
config?: Config
|
||||
@@ -61,6 +62,7 @@ export default (
|
||||
// so pnpm will only print a few warnings and report the total number of the unprinted warnings.
|
||||
function makeWarningReporter (
|
||||
opts: {
|
||||
appendOnly: boolean
|
||||
cwd: string
|
||||
zoomOutCurrent: boolean
|
||||
}
|
||||
@@ -69,7 +71,7 @@ function makeWarningReporter (
|
||||
let collapsedWarnings: Rx.Subject<{ msg: string }>
|
||||
return (obj: { prefix: string, message: string }) => {
|
||||
warningsCounter++
|
||||
if (warningsCounter <= MAX_SHOWN_WARNINGS) {
|
||||
if (opts.appendOnly || warningsCounter <= MAX_SHOWN_WARNINGS) {
|
||||
return Rx.of({ msg: autozoom(opts.cwd, obj.prefix, formatWarn(obj.message), opts) })
|
||||
}
|
||||
const warningMsg = formatWarn(`${warningsCounter - MAX_SHOWN_WARNINGS} other warnings`)
|
||||
|
||||
@@ -1059,3 +1059,36 @@ ${WARN} 2 other warnings`)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
test('warnings are not collapsed when append-only is true', (done) => {
|
||||
const prefix = process.cwd()
|
||||
const output$ = toOutput$({
|
||||
context: {
|
||||
argv: ['install'],
|
||||
config: { dir: prefix } as Config,
|
||||
},
|
||||
reportingOptions: {
|
||||
appendOnly: true,
|
||||
logLevel: 'warn',
|
||||
},
|
||||
streamParser: createStreamParser(),
|
||||
})
|
||||
|
||||
logger.warn({ message: 'Some issue 1', prefix })
|
||||
logger.warn({ message: 'Some issue 2', prefix })
|
||||
logger.warn({ message: 'Some issue 3', prefix })
|
||||
logger.warn({ message: 'Some issue 4', prefix })
|
||||
logger.warn({ message: 'Some issue 5', prefix })
|
||||
logger.warn({ message: 'Some issue 6', prefix })
|
||||
logger.warn({ message: 'Some issue 7', prefix })
|
||||
|
||||
expect.assertions(1)
|
||||
|
||||
output$.pipe(skip(6), take(1)).subscribe({
|
||||
complete: () => done(),
|
||||
error: done,
|
||||
next: output => {
|
||||
expect(output).toBe(`${WARN} Some issue 7`)
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user