Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

Commit

Permalink
fix: do not enable progress while paused
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekarrys committed Oct 19, 2022
1 parent 35651cf commit add709d
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,12 @@ log.setGaugeTemplate = function (template) {
}

log.enableProgress = function () {
if (this.progressEnabled) {
if (this.progressEnabled || this._paused) {
return
}

this.progressEnabled = true
this.tracker.on('change', this.showProgress)
if (this._paused) {
return
}

this.gauge.enable()
}

Expand Down
25 changes: 25 additions & 0 deletions test/progress.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ function didActions (t, msg, output) {

function resetTracker () {
log.disableProgress()
log.resume()
log.tracker = new Progress.TrackerGroup()
log.enableProgress()
actions = []
Expand Down Expand Up @@ -213,3 +214,27 @@ test('newStream', function (t) {
}]])
t.equal(log.tracker.completed(), 1, 'Overall completion')
})

test('enableProgress while paused', function (t) {
t.plan(2)
resetTracker()
log.disableProgress()
actions = []
log.pause()
log.enableProgress()
didActions(t, 'enableProgress', [])
log.enableProgress()
didActions(t, 'enableProgress again', [])
})

test('pause while enableProgress', function (t) {
t.plan(8)
resetTracker()
log.disableProgress()
actions = []
log.enableProgress()
log.pause()
didActions(t, 'enableProgress', [['enable'], ['disable']])
log.resume()
didActions(t, 'enableProgress', [['enable']])
})

0 comments on commit add709d

Please sign in to comment.