diff --git a/lib/log.js b/lib/log.js index be650c6..38106ea 100644 --- a/lib/log.js +++ b/lib/log.js @@ -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() } diff --git a/test/progress.js b/test/progress.js index b1339b2..e45f663 100644 --- a/test/progress.js +++ b/test/progress.js @@ -70,6 +70,7 @@ function didActions (t, msg, output) { function resetTracker () { log.disableProgress() + log.resume() log.tracker = new Progress.TrackerGroup() log.enableProgress() actions = [] @@ -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']]) +})