summaryrefslogtreecommitdiff
path: root/deps/npm/lib/utils/no-progress-while-running.js
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/utils/no-progress-while-running.js')
-rw-r--r--deps/npm/lib/utils/no-progress-while-running.js23
1 files changed, 23 insertions, 0 deletions
diff --git a/deps/npm/lib/utils/no-progress-while-running.js b/deps/npm/lib/utils/no-progress-while-running.js
new file mode 100644
index 0000000000..961fa8b555
--- /dev/null
+++ b/deps/npm/lib/utils/no-progress-while-running.js
@@ -0,0 +1,23 @@
+'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)
+ }
+}