Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(gatsby-cli): fix timers on progress bar #28684

Merged
merged 6 commits into from
Jan 5, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions packages/gatsby-cli/src/reporter/loggers/yurnalist/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,27 @@ export function initializeYurnalistLogger(): void {
activities[action.payload.id] = activity
} else if (action.payload.type === ActivityTypes.Progress) {
const bar = new ProgressBar(
` [:bar] :current/:total :elapsed s :percent ${action.payload.text}`,
` [:bar] :current/:total :elapsed s :rate /s :percent ${action.payload.text}`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit (feel free to ignore)

Suggested change
` [:bar] :current/:total :elapsed s :rate /s :percent ${action.payload.text}`,
` [:bar] :current/:total :elapseds :rate/s :percent ${action.payload.text}`,

extra space there make it look a bit weird (like it was something separate) - this change does in fact result in

-[=====-------------------------] 18/100 1.5 s 12 /s 18% test #1
+[=====-------------------------] 18/100 1.5s 12/s 18% test #1

"postfixes" are "attached" to their numbers which to me make it more clear what those are (IMO)

but up to you and feel free to ignore

{
total: action.payload.total,
curr: action.payload.current,
total: Math.max(action.payload.total || 1, 1) || 1, // Not zero. Otherwise you get 0/0 errors.
// curr: action.payload.current, // see below
width: 30,
clear: true,
}
)

// There is a bug in the `progress` package where the timer doesn't
// start until the first tick and setting `curr` will cause the
// time/eta to remain zero: https://github.com/visionmedia/node-progress/issues/81
// This is a workaround although the eta will initially be wrong
// until it settles, if starting at non-zero.
if (
typeof action.payload.current === `number` &&
action.payload.current >= 0
) {
bar.tick(action.payload.current)
}

activities[action.payload.id] = {
text: undefined,
statusText: undefined,
Expand Down