Skip to content

Commit

Permalink
fix pulseWhileDone promise handling
Browse files Browse the repository at this point in the history
Small an oversight from the Bluebird -> Promise refactor.

Fix #1695
  • Loading branch information
isaacs committed Aug 21, 2020
1 parent 1faa5b3 commit 10fcff7
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions lib/utils/pulse-till-done.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 10fcff7

Please sign in to comment.