Skip to content

Commit

Permalink
Fix: only allow one waiting message per progress bar (#167) (#178)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmercm authored Nov 20, 2022
1 parent 4b9726c commit 6cd9431
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/console/progressBarCLI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export default class ProgressBarCLI extends ProgressBar {

private readonly singleBarFormatted: SingleBarFormatted;

private waitingMessageTimeout?: NodeJS.Timeout;

private constructor(logger: Logger, singleBarFormatted: SingleBarFormatted) {
super();
this.logger = logger;
Expand Down Expand Up @@ -110,12 +112,14 @@ export default class ProgressBarCLI extends ProgressBar {
* user know that there is still something processing.
*/
setWaitingMessage(waitingMessage: string, timeout = 10_000): NodeJS.Timeout {
return setTimeout(async () => {
clearTimeout(this.waitingMessageTimeout);
this.waitingMessageTimeout = setTimeout(async () => {
this.singleBarFormatted.getSingleBar().update({
waitingMessage,
} as ProgressBarPayload);
await ProgressBarCLI.render(true);
}, timeout);
return this.waitingMessageTimeout;
}

async increment(): Promise<void> {
Expand Down

0 comments on commit 6cd9431

Please sign in to comment.