1234567891011121314151617181920212223242526 |
- const log = require('npmlog')
- let pulseTimer = null
- const withPromise = async (promise) => {
- pulseStart()
- try {
- return await promise
- } finally {
- pulseStop()
- }
- }
- const pulseStart = () => {
- pulseTimer = pulseTimer || setInterval(() => {
- log.gauge.pulse('')
- }, 150)
- }
- const pulseStop = () => {
- clearInterval(pulseTimer)
- pulseTimer = null
- }
- module.exports = {
- withPromise,
- }
|