mirror of
https://github.com/zhigang1992/now-deployment.git
synced 2026-06-16 02:34:33 +08:00
14 lines
281 B
TypeScript
14 lines
281 B
TypeScript
import wait from './output/wait';
|
|
|
|
export default async function withSpinner<T>(msg: string, f: () => Promise<T>) {
|
|
const stopSpinner = wait(msg);
|
|
try {
|
|
const res = await f();
|
|
stopSpinner();
|
|
return res;
|
|
} catch (error) {
|
|
stopSpinner();
|
|
throw error;
|
|
}
|
|
}
|