mirror of
https://github.com/pnpm/pnpm.git
synced 2026-05-18 22:02:53 -04: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(
|
reportMisc(
|
||||||
log$,
|
log$,
|
||||||
{
|
{
|
||||||
|
appendOnly: opts.appendOnly === true,
|
||||||
config: opts.config,
|
config: opts.config,
|
||||||
cwd,
|
cwd,
|
||||||
logLevel: opts.logLevel,
|
logLevel: opts.logLevel,
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export default (
|
|||||||
other: Rx.Observable<Log>
|
other: Rx.Observable<Log>
|
||||||
},
|
},
|
||||||
opts: {
|
opts: {
|
||||||
|
appendOnly: boolean
|
||||||
cwd: string
|
cwd: string
|
||||||
logLevel?: LogLevel
|
logLevel?: LogLevel
|
||||||
config?: Config
|
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.
|
// so pnpm will only print a few warnings and report the total number of the unprinted warnings.
|
||||||
function makeWarningReporter (
|
function makeWarningReporter (
|
||||||
opts: {
|
opts: {
|
||||||
|
appendOnly: boolean
|
||||||
cwd: string
|
cwd: string
|
||||||
zoomOutCurrent: boolean
|
zoomOutCurrent: boolean
|
||||||
}
|
}
|
||||||
@@ -69,7 +71,7 @@ function makeWarningReporter (
|
|||||||
let collapsedWarnings: Rx.Subject<{ msg: string }>
|
let collapsedWarnings: Rx.Subject<{ msg: string }>
|
||||||
return (obj: { prefix: string, message: string }) => {
|
return (obj: { prefix: string, message: string }) => {
|
||||||
warningsCounter++
|
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) })
|
return Rx.of({ msg: autozoom(opts.cwd, obj.prefix, formatWarn(obj.message), opts) })
|
||||||
}
|
}
|
||||||
const warningMsg = formatWarn(`${warningsCounter - MAX_SHOWN_WARNINGS} other warnings`)
|
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