fix: don't prefix output for dlx

This commit is contained in:
Zoltan Kochan
2023-08-21 17:21:05 +03:00
parent bc5d3ceda9
commit f432cb11ac
4 changed files with 21 additions and 7 deletions

View File

@@ -0,0 +1,6 @@
---
"@pnpm/default-reporter": patch
"pnpm": patch
---
Don't prefix install output for the dlx command.

View File

@@ -247,11 +247,12 @@ export function toOutput$ (
summary: Rx.from(summaryPushStream),
updateCheck: Rx.from(updateCheckPushStream),
}
const cmd = opts.context.argv[0]
const outputs: Array<Rx.Observable<Rx.Observable<{ msg: string }>>> = reporterForClient(
log$,
{
appendOnly: opts.reportingOptions?.appendOnly,
cmd: opts.context.argv[0],
cmd,
config: opts.context.config,
env: opts.context.env ?? process.env,
filterPkgsDiff: opts.filterPkgsDiff,
@@ -264,7 +265,7 @@ export function toOutput$ (
throttleProgress: opts.reportingOptions?.throttleProgress,
width: opts.reportingOptions?.outputMaxWidth,
hideAddedPkgsProgress: opts.reportingOptions?.hideAddedPkgsProgress,
hideProgressPrefix: opts.reportingOptions?.hideProgressPrefix,
hideProgressPrefix: opts.reportingOptions?.hideProgressPrefix ?? (cmd === 'dlx'),
}
)

View File

@@ -132,6 +132,7 @@ export function reporterForClient (
cwd,
isRecursive: opts.isRecursive,
width,
hideProgressPrefix: opts.hideProgressPrefix,
})
)
}

View File

@@ -20,8 +20,15 @@ export function reportStats (
cwd: string
isRecursive: boolean
width: number
hideProgressPrefix?: boolean
}
) {
if (opts.hideProgressPrefix) {
return [statsForCurrentPackage(log$.stats, {
cmd: opts.cmd,
width: opts.width,
})]
}
const stats$ = opts.isRecursive
? log$.stats
: log$.stats.pipe(filter((log) => log.prefix !== opts.cwd))
@@ -35,9 +42,10 @@ export function reportStats (
]
if (!opts.isRecursive) {
outputs.push(statsForCurrentPackage(log$.stats, {
outputs.push(statsForCurrentPackage(log$.stats.pipe(
filter((log) => log.prefix === opts.cwd)
), {
cmd: opts.cmd,
currentPrefix: opts.cwd,
width: opts.width,
}))
}
@@ -49,13 +57,11 @@ function statsForCurrentPackage (
stats$: Rx.Observable<StatsLog>,
opts: {
cmd: string
currentPrefix: string
width: number
}
) {
return stats$.pipe(
filter((log) => log.prefix === opts.currentPrefix),
take((opts.cmd === 'install' || opts.cmd === 'install-test' || opts.cmd === 'add' || opts.cmd === 'update') ? 2 : 1),
take((opts.cmd === 'install' || opts.cmd === 'install-test' || opts.cmd === 'add' || opts.cmd === 'update' || opts.cmd === 'dlx') ? 2 : 1),
reduce((acc, log) => {
if (typeof log['added'] === 'number') {
acc['added'] = log['added']