mirror of
https://github.com/morten-olsen/mini-loader.git
synced 2026-02-08 01:36:26 +01:00
16 lines
314 B
TypeScript
16 lines
314 B
TypeScript
import ora from 'ora';
|
|
|
|
const step = async <T>(message: string, fn: () => Promise<T>): Promise<T> => {
|
|
const spinner = ora(message).start();
|
|
try {
|
|
const result = await fn();
|
|
await spinner.succeed();
|
|
return result;
|
|
} catch (err) {
|
|
await spinner.fail();
|
|
throw err;
|
|
}
|
|
};
|
|
|
|
export { step };
|