Skip to content

Commit 2d0dc37

Browse files
committed
fix: protect against non-existent bar
1 parent 37f85b7 commit 2d0dc37

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/ux/progress.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class Progress extends UxBase {
3434
*/
3535
public setTotal(total: number): void {
3636
this.total = total;
37-
this.bar.setTotal(total);
37+
if (this.bar) this.bar.setTotal(total);
3838
}
3939

4040
/**
@@ -55,7 +55,7 @@ export class Progress extends UxBase {
5555
}) as Progress.Bar;
5656

5757
this.bar.setTotal(total);
58-
// this.maybeNoop(() => startProgressBar(this.bar, total, payload));
58+
5959
this.maybeNoop(() => {
6060
this._start(total, payload);
6161
});
@@ -65,22 +65,24 @@ export class Progress extends UxBase {
6565
* Update the progress bar.
6666
*/
6767
public update(num: number, payload = {}): void {
68-
this.bar.update(num, payload);
68+
if (this.bar) this.bar.update(num, payload);
6969
}
7070

7171
/**
7272
* Update the progress bar with the final number and stop it.
7373
*/
7474
public finish(payload = {}): void {
75-
this.bar.update(this.total, payload);
76-
this.bar.stop();
75+
if (this.bar) {
76+
this.bar.update(this.total, payload);
77+
this.bar.stop();
78+
}
7779
}
7880

7981
/**
8082
* Stop the progress bar.
8183
*/
8284
public stop(): void {
83-
this.bar.stop();
85+
if (this.bar) this.bar.stop();
8486
}
8587

8688
private _start(total: number, payload: Progress.Payload = {}): void {

0 commit comments

Comments
 (0)