• File: no-progress-while-running.js
  • Full Path: /home6/laduliya/test.mydthpay.com/node_modules/npm/lib/no-progress-while-running.js
  • Date Modified: 10/26/1985 11:45 AM
  • File size: 541 bytes
  • MIME-type: text/plain
  • Charset: utf-8
'use strict'
var log = require('npmlog')
var progressEnabled
var running = 0

var startRunning = exports.startRunning = function () {
  if (progressEnabled == null) progressEnabled = log.progressEnabled
  if (progressEnabled) log.disableProgress()
  ++running
}

var stopRunning = exports.stopRunning = function () {
  --running
  if (progressEnabled && running === 0) log.enableProgress()
}

exports.tillDone = function noProgressTillDone (cb) {
  startRunning()
  return function () {
    stopRunning()
    cb.apply(this, arguments)
  }
}