fix(reporter): always print the final progress stats

This commit is contained in:
Zoltan Kochan
2020-09-16 03:11:30 +03:00
parent e45c97d35a
commit 3b8e3b6b19
3 changed files with 15 additions and 11 deletions

View File

@@ -0,0 +1,5 @@
---
"@pnpm/default-reporter": patch
---
Always print the final progress stats.

View File

@@ -54,7 +54,7 @@ export default function (
const width = opts.width ?? process.stdout.columns ?? 80
const cwd = opts.pnpmConfig?.dir ?? process.cwd()
const throttle = typeof opts.throttleProgress === 'number' && opts.throttleProgress > 0
? throttleTime(opts.throttleProgress)
? throttleTime(opts.throttleProgress, undefined, { leading: true, trailing: true })
: undefined
const outputs: Array<Rx.Observable<Rx.Observable<{msg: string}>>> = [

View File

@@ -53,18 +53,17 @@ function throttledProgressOutput (
importingDone$: Rx.Observable<boolean>,
progress$: Rx.Observable<ProgressStats>
) {
// Reporting is done every `throttleProgress` milliseconds
// and once all packages are fetched.
return Rx.combineLatest(
throttle ? progress$.pipe(throttle) : progress$,
let combinedProgress = Rx.combineLatest(
progress$,
importingDone$
)
.pipe(
map(createStatusMessage),
// Avoid logs after all resolved packages were downloaded.
// Fixing issue: https://github.com/pnpm/pnpm/issues/1028#issuecomment-364782901
takeWhile((msg) => msg['done'] !== true, true)
)
// Avoid logs after all resolved packages were downloaded.
// Fixing issue: https://github.com/pnpm/pnpm/issues/1028#issuecomment-364782901
.pipe(takeWhile(([, importingDone]) => !importingDone, true))
if (throttle) {
combinedProgress = combinedProgress.pipe(throttle)
}
return combinedProgress.pipe(map(createStatusMessage))
}
function getModulesInstallProgress$ (