mirror of
https://github.com/pnpm/pnpm.git
synced 2025-12-23 23:29:17 -05:00
fix(reporter): don't print empty sections in summary
This commit is contained in:
5
.changeset/late-elephants-shout.md
Normal file
5
.changeset/late-elephants-shout.md
Normal file
@@ -0,0 +1,5 @@
|
||||
---
|
||||
"@pnpm/default-reporter": patch
|
||||
---
|
||||
|
||||
Don't print empty sections in the summary, when results are filtered.
|
||||
@@ -44,7 +44,7 @@ export function reportSummary (
|
||||
const pkgsDiff$ = getPkgsDiff(log$, { prefix: opts.cwd })
|
||||
|
||||
const summaryLog$ = log$.summary.pipe(take(1))
|
||||
const _printDiffs = printDiffs.bind(null, { prefix: opts.cwd, filterPkgsDiff: opts.filterPkgsDiff })
|
||||
const _printDiffs = printDiffs.bind(null, { prefix: opts.cwd })
|
||||
|
||||
return Rx.combineLatest(
|
||||
pkgsDiff$,
|
||||
@@ -55,7 +55,12 @@ export function reportSummary (
|
||||
map(([pkgsDiff]) => {
|
||||
let msg = ''
|
||||
for (const depType of ['prod', 'optional', 'peer', 'dev', 'nodeModulesOnly'] as const) {
|
||||
const diffs: PackageDiff[] = Object.values(pkgsDiff[depType as keyof typeof pkgsDiff])
|
||||
let diffs: PackageDiff[] = Object.values(pkgsDiff[depType as keyof typeof pkgsDiff])
|
||||
if (opts.filterPkgsDiff) {
|
||||
// This filtering is only used by Bit CLI currently.
|
||||
// Related PR: https://github.com/teambit/bit/pull/7176
|
||||
diffs = diffs.filter((pkgDiff) => opts.filterPkgsDiff!(pkgDiff))
|
||||
}
|
||||
if (diffs.length > 0) {
|
||||
msg += EOL
|
||||
if (opts.pnpmConfig?.global) {
|
||||
@@ -85,15 +90,9 @@ export type FilterPkgsDiff = (pkgsDiff: PackageDiff) => boolean
|
||||
function printDiffs (
|
||||
opts: {
|
||||
prefix: string
|
||||
filterPkgsDiff?: FilterPkgsDiff
|
||||
},
|
||||
pkgsDiff: PackageDiff[]
|
||||
) {
|
||||
// This filtering is only used by Bit CLI currently.
|
||||
// Related PR: https://github.com/teambit/bit/pull/7176
|
||||
if (opts.filterPkgsDiff) {
|
||||
pkgsDiff = pkgsDiff.filter((pkgDiff) => opts.filterPkgsDiff!(pkgDiff))
|
||||
}
|
||||
// Sorts by alphabet then by removed/added
|
||||
// + ava 0.10.0
|
||||
// - chalk 1.0.0
|
||||
|
||||
@@ -265,6 +265,17 @@ test('prints summary without the filtered out entries', (done) => {
|
||||
},
|
||||
prefix,
|
||||
})
|
||||
rootLogger.debug({
|
||||
added: {
|
||||
dependencyType: 'dev',
|
||||
id: 'registry.npmjs.org/qar/2.0.0',
|
||||
latest: '1.0.0', // this won't be printed in summary because latest is less than current version
|
||||
name: 'qar',
|
||||
realName: 'qar',
|
||||
version: '2.0.0',
|
||||
},
|
||||
prefix,
|
||||
})
|
||||
packageManifestLogger.debug({
|
||||
prefix,
|
||||
updated: {
|
||||
|
||||
Reference in New Issue
Block a user