Skip to content

Commit

Permalink
Remove our onExit handler when disabling gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
iarna committed Feb 8, 2017
1 parent 31bc882 commit 44b5b20
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,8 @@ function Gauge (arg1, arg2) {
this._$$doRedraw = callWith(this, this._doRedraw)
this._$$handleSizeChange = callWith(this, this._handleSizeChange)

if (options.cleanupOnExit == null || options.cleanupOnExit) {
onExit(callWith(this, this.disable))
}
this._cleanupOnExit = options.cleanupOnExit == null || options.cleanupOnExit
this._removeOnExit = null

if (options.enabled || (options.enabled == null && this._tty && this._tty.isTTY)) {
this.enable()
Expand Down Expand Up @@ -147,6 +146,9 @@ Gauge.prototype.disable = function () {
}

Gauge.prototype._enableEvents = function () {
if (this._cleanupOnExit) {
this._removeOnExit = onExit(callWith(this, this.disable))
}
this._tty.on('resize', this._$$handleSizeChange)
if (this._fixedFramerate) {
this.redrawTracker = setInterval(this._$$doRedraw, this._updateInterval)
Expand All @@ -157,6 +159,7 @@ Gauge.prototype._enableEvents = function () {
Gauge.prototype._disableEvents = function () {
this._tty.removeListener('resize', this._$$handleSizeChange)
if (this._fixedFramerate) clearInterval(this.redrawTracker)
if (this._removeOnExit) this._removeOnExit()
}

Gauge.prototype.hide = function (cb) {
Expand Down

0 comments on commit 44b5b20

Please sign in to comment.