@lobehub/chat
Version:
Lobe Chat - an open-source, high-performance chatbot framework that supports speech synthesis, multimodal, and extensible Function Call plugin system. Supports one-click free deployment of your private ChatGPT/LLM web application.
16 lines (14 loc) • 512 B
text/typescript
import { mkdirSync, statSync } from 'node:fs';
export const makeSureDirExist = (dir: string) => {
try {
statSync(dir);
} catch {
// 使用 recursive: true,如果目录已存在则此操作无效果,如果不存在则创建
try {
mkdirSync(dir, { recursive: true });
} catch (mkdirError: any) {
// 如果创建目录失败(例如权限问题),则抛出错误
throw new Error(`Could not create target directory: ${dir}. Error: ${mkdirError.message}`);
}
}
};