diff --git a/src/util/cli.ts b/src/util/cli.ts index f8918b0..2208613 100644 --- a/src/util/cli.ts +++ b/src/util/cli.ts @@ -17,3 +17,14 @@ export function startActionSpinner(action: string) { export function stopActionSpinner(spinner: ora.Ora) { spinner.stopAndPersist() } + +export async function withSpinner( + action: string, + callback: (spinner: ora.Ora) => Promise, +) { + let spinner = createActionSpinner(action) + let ret = await callback(spinner) + stopActionSpinner(spinner) + + return ret +}