- 删除根目录中重复的 NestJS 配置文件 - 删除 tsconfig.json, tsconfig.build.json, eslint.config.mjs, .prettierrc - 保留 wwjcloud-nest/ 目录中的完整配置 - 避免配置冲突,确保项目结构清晰
27 lines
560 B
TypeScript
27 lines
560 B
TypeScript
import type { Ora } from 'ora';
|
|
|
|
import ora from 'ora';
|
|
|
|
interface SpinnerOptions {
|
|
failedText?: string;
|
|
successText?: string;
|
|
title: string;
|
|
}
|
|
export async function spinner<T>(
|
|
{ failedText, successText, title }: SpinnerOptions,
|
|
callback: () => Promise<T>,
|
|
): Promise<T> {
|
|
const loading: Ora = ora(title).start();
|
|
|
|
try {
|
|
const result = await callback();
|
|
loading.succeed(successText || 'Success!');
|
|
return result;
|
|
} catch (error) {
|
|
loading.fail(failedText || 'Failed!');
|
|
throw error;
|
|
} finally {
|
|
loading.stop();
|
|
}
|
|
}
|