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