From 7aa83fe8d1fdacc6cd6441d094e751bced1d3781 Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Tue, 9 Nov 2021 19:50:55 -0800 Subject: [PATCH] util: cli: Add common spinner helpers --- src/util/cli.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/util/cli.ts diff --git a/src/util/cli.ts b/src/util/cli.ts new file mode 100644 index 0000000..705fce1 --- /dev/null +++ b/src/util/cli.ts @@ -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() +}