diff options
| author | rejbasket <39080670+rejbasket@users.noreply.github.com> | 2023-05-22 22:33:19 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-05-22 22:33:19 +0200 |
| commit | ef6f6580df6e8fbce913eecc1fe7e0f8caf1315b (patch) | |
| tree | c1119a5d1affd44ad27e60cc6981ac98534c518d /electron/service/utils/spinner.js | |
| parent | da54f104e6bf5d0e98f7479cf1d060c76e0b01f2 (diff) | |
Update electron version to v14.2.9 (#2214)
Authored-by: rejbasket
Co-authored-by: Kaalleen
Co-authored-by: Lex Neva
Diffstat (limited to 'electron/service/utils/spinner.js')
| -rw-r--r-- | electron/service/utils/spinner.js | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/electron/service/utils/spinner.js b/electron/service/utils/spinner.js new file mode 100644 index 00000000..d643a933 --- /dev/null +++ b/electron/service/utils/spinner.js @@ -0,0 +1,57 @@ +'use strict' + +const ora = require('ora') +const chalk = require('chalk') + +const spinner = ora() +let lastMsg = null +let isPaused = false + +exports.logWithSpinner = (symbol, msg) => { + if (!msg) { + msg = symbol + symbol = chalk.green('✔') + } + if (lastMsg) { + spinner.stopAndPersist({ + symbol: lastMsg.symbol, + text: lastMsg.text, + }) + } + spinner.text = ' ' + msg + lastMsg = { + symbol: symbol + ' ', + text: msg, + } + spinner.start() +} + +exports.stopSpinner = (persist) => { + if (lastMsg && persist !== false) { + spinner.stopAndPersist({ + symbol: lastMsg.symbol, + text: lastMsg.text, + }) + } else { + spinner.stop() + } + lastMsg = null +} + +exports.pauseSpinner = () => { + if (spinner.isSpinning) { + spinner.stop() + isPaused = true + } +} + +exports.resumeSpinner = () => { + if (isPaused) { + spinner.start() + isPaused = false + } +} + +exports.failSpinner = (text) => { + spinner.fail(text) +} |
