Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lib/utils
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2020-08-21 03:39:37 +0300
committerisaacs <i@izs.me>2020-08-21 03:46:01 +0300
commit10fcff73a3381ea5e6dcb03888679ae4b501d2f0 (patch)
tree7109151ee4163467bf4d29e606dbee46c68f6c9f /lib/utils
parent1faa5b33dcc6d7e4eba1c0d85ad30cf0c237c9e1 (diff)
fix pulseWhileDone promise handling
Small an oversight from the Bluebird -> Promise refactor. Fix #1695
Diffstat (limited to 'lib/utils')
-rw-r--r--lib/utils/pulse-till-done.js15
1 files changed, 7 insertions, 8 deletions
diff --git a/lib/utils/pulse-till-done.js b/lib/utils/pulse-till-done.js
index 22080739a..a533c0644 100644
--- a/lib/utils/pulse-till-done.js
+++ b/lib/utils/pulse-till-done.js
@@ -25,18 +25,17 @@ module.exports = function (prefix, cb) {
cb(er, ...args)
}
}
-module.exports.withPromise = pulseWhile
-function pulseWhile (prefix, promise) {
+const pulseWhile = async (prefix, promise) => {
if (!promise) {
promise = prefix
prefix = ''
}
pulseStart(prefix)
- return Promise.resolve(promise)
- .then(() => pulseStop())
- .catch(er => {
- pulseStop()
- throw er
- })
+ try {
+ return await promise
+ } finally {
+ pulseStop()
+ }
}
+module.exports.withPromise = pulseWhile