import ora from 'ora'; type FnToSpin = (options: T) => Promise; export const useSpinner = (spinnerLabel: string, fn: FnToSpin, killProcess = true) => { return async (options: T) => { const spinner = ora(spinnerLabel); spinner.start(); try { await fn(options); spinner.succeed(); } catch (e) { spinner.fail(e); if (killProcess) { process.exit(1); } } }; };