fix: don't show info messages on --loglevel=error (#9241)

This commit is contained in:
Zoltan Kochan
2025-03-08 12:19:24 +01:00
committed by GitHub
parent 7072838e7d
commit f8c8e3f057
2 changed files with 36 additions and 34 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/default-reporter": patch
"pnpm": patch
---
Don't show info output when `--loglevel=error` is used.

View File

@@ -82,13 +82,6 @@ export function reporterForClient (
: undefined
const outputs: Array<Rx.Observable<Rx.Observable<{ msg: string }>>> = [
reportLifecycleScripts(log$, {
appendOnly: (opts.appendOnly === true || opts.streamLifecycleOutput) && !opts.hideLifecycleOutput,
aggregateOutput: opts.aggregateOutput,
hideLifecyclePrefix: opts.hideLifecyclePrefix,
cwd,
width,
}),
reportMisc(
log$,
{
@@ -100,25 +93,12 @@ export function reporterForClient (
peerDependencyRules: opts.peerDependencyRules,
}
),
reportInstallChecks(log$.installCheck, { cwd }),
reportScope(log$.scope, { isRecursive: opts.isRecursive, cmd: opts.cmd }),
reportSkippedOptionalDependencies(log$.skippedOptionalDependency, { cwd }),
reportHooks(log$.hook, { cwd, isRecursive: opts.isRecursive }),
reportUpdateCheck(log$.updateCheck, opts),
]
if (opts.cmd !== 'dlx') {
outputs.push(reportContext(log$, { cwd }))
}
// logLevelNumber: 0123 = error warn info debug
const logLevelNumber = LOG_LEVEL_NUMBER[opts.logLevel ?? 'info'] ?? LOG_LEVEL_NUMBER['info']
const showInfo = logLevelNumber >= LOG_LEVEL_NUMBER.info
if (opts.cmd in PRINT_EXECUTION_TIME_IN_COMMANDS && showInfo) {
outputs.push(reportExecutionTime(log$.executionTime))
}
if (logLevelNumber >= LOG_LEVEL_NUMBER.warn) {
outputs.push(
reportPeerDependencyIssues(log$, opts.peerDependencyRules),
@@ -131,7 +111,25 @@ export function reporterForClient (
}
if (showInfo) {
if (opts.cmd in PRINT_EXECUTION_TIME_IN_COMMANDS) {
outputs.push(reportExecutionTime(log$.executionTime))
}
if (opts.cmd !== 'dlx') {
outputs.push(reportContext(log$, { cwd }))
}
outputs.push(
reportLifecycleScripts(log$, {
appendOnly: (opts.appendOnly === true || opts.streamLifecycleOutput) && !opts.hideLifecycleOutput,
aggregateOutput: opts.aggregateOutput,
hideLifecyclePrefix: opts.hideLifecyclePrefix,
cwd,
width,
}),
reportInstallChecks(log$.installCheck, { cwd }),
reportScope(log$.scope, { isRecursive: opts.isRecursive, cmd: opts.cmd }),
reportSkippedOptionalDependencies(log$.skippedOptionalDependency, { cwd }),
reportHooks(log$.hook, { cwd, isRecursive: opts.isRecursive }),
reportUpdateCheck(log$.updateCheck, opts),
reportProgress(log$, {
cwd,
throttle,
@@ -146,20 +144,18 @@ export function reporterForClient (
hideProgressPrefix: opts.hideProgressPrefix,
})
)
}
if (!opts.appendOnly && showInfo) {
outputs.push(reportBigTarballProgress(log$))
}
if (!opts.isRecursive && showInfo) {
outputs.push(reportSummary(log$, {
cmd: opts.cmd,
cwd,
env: opts.env,
filterPkgsDiff: opts.filterPkgsDiff,
pnpmConfig: opts.pnpmConfig,
}))
if (!opts.appendOnly) {
outputs.push(reportBigTarballProgress(log$))
}
if (!opts.isRecursive) {
outputs.push(reportSummary(log$, {
cmd: opts.cmd,
cwd,
env: opts.env,
filterPkgsDiff: opts.filterPkgsDiff,
pnpmConfig: opts.pnpmConfig,
}))
}
}
return outputs