parent
3b3d64cf62
commit
2dadce7391
@ -1,12 +1,18 @@ |
||||
const ora = require('ora'); |
||||
|
||||
module.exports = async (text, promise, callback) => { |
||||
let spin = ora(text).start(); |
||||
await promise |
||||
.catch(e => callback(spin, e)) |
||||
.then((...args) => { |
||||
spin.stop(); |
||||
spin.clear(); |
||||
callback(spin, args); |
||||
}); |
||||
return new Promise(async (resolve, reject) => { |
||||
let spin = ora(text).start(); |
||||
return await promise |
||||
.catch(e => { |
||||
spin.stop(); |
||||
spin.clear(); |
||||
return reject(e) |
||||
}) |
||||
.then((...args) => { |
||||
spin.stop(); |
||||
spin.clear(); |
||||
return callback ? resolve(callback(spin, args)) : resolve(true); |
||||
}); |
||||
}); |
||||
}; |
Loading…
Reference in new issue