fix(reporter): do not collapse warnings when append-only

This commit is contained in:
Zoltan Kochan
2021-07-24 02:46:26 +03:00
parent f63c034c6a
commit 67c6a67f98
4 changed files with 42 additions and 1 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/default-reporter": patch
---
Do not collapse warnings when reporting is append-only.

View File

@@ -73,6 +73,7 @@ export default function (
reportMisc(
log$,
{
appendOnly: opts.appendOnly === true,
config: opts.config,
cwd,
logLevel: opts.logLevel,

View File

@@ -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`)

View File

@@ -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`)
},
})
})