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

Commit add709d

Browse files
committed
fix: do not enable progress while paused
Ref: npm/cli#4527
1 parent 35651cf commit add709d

File tree

2 files changed

+26
-5
lines changed

2 files changed

+26
-5
lines changed

lib/log.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,12 @@ log.setGaugeTemplate = function (template) {
7979
}
8080

8181
log.enableProgress = function () {
82-
if (this.progressEnabled) {
82+
if (this.progressEnabled || this._paused) {
8383
return
8484
}
8585

8686
this.progressEnabled = true
8787
this.tracker.on('change', this.showProgress)
88-
if (this._paused) {
89-
return
90-
}
91-
9288
this.gauge.enable()
9389
}
9490

test/progress.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ function didActions (t, msg, output) {
7070

7171
function resetTracker () {
7272
log.disableProgress()
73+
log.resume()
7374
log.tracker = new Progress.TrackerGroup()
7475
log.enableProgress()
7576
actions = []
@@ -213,3 +214,27 @@ test('newStream', function (t) {
213214
}]])
214215
t.equal(log.tracker.completed(), 1, 'Overall completion')
215216
})
217+
218+
test('enableProgress while paused', function (t) {
219+
t.plan(2)
220+
resetTracker()
221+
log.disableProgress()
222+
actions = []
223+
log.pause()
224+
log.enableProgress()
225+
didActions(t, 'enableProgress', [])
226+
log.enableProgress()
227+
didActions(t, 'enableProgress again', [])
228+
})
229+
230+
test('pause while enableProgress', function (t) {
231+
t.plan(8)
232+
resetTracker()
233+
log.disableProgress()
234+
actions = []
235+
log.enableProgress()
236+
log.pause()
237+
didActions(t, 'enableProgress', [['enable'], ['disable']])
238+
log.resume()
239+
didActions(t, 'enableProgress', [['enable']])
240+
})

0 commit comments

Comments
 (0)