util: cli: Add common spinner helpers

This commit is contained in:
Danny Lin 2021-11-09 19:50:55 -08:00
parent e5c8ecfb4e
commit 7aa83fe8d1

17
src/util/cli.ts Normal file
View file

@ -0,0 +1,17 @@
import * as ora from 'ora'
import * as chalk from 'chalk'
export function createActionSpinner(action: string) {
return ora({
prefixText: chalk.bold(chalk.greenBright(action)),
color: 'green',
})
}
export function startActionSpinner(action: string) {
return createActionSpinner(action).start()
}
export function stopActionSpinner(spinner: ora.Ora) {
spinner.stopAndPersist()
}