* 配置加载器
()
| 53 | * 配置加载器 |
| 54 | */ |
| 55 | function loadConfig() { |
| 56 | try { |
| 57 | // 尝试从工作目录加载配置文件 |
| 58 | const configPath = path.join(process.cwd(), 'cc-reverse.config.js'); |
| 59 | |
| 60 | // 检查配置文件是否存在 |
| 61 | if (fs.existsSync(configPath)) { |
| 62 | logger.info(`加载配置文件: ${configPath}`); |
| 63 | |
| 64 | // 加载配置文件 |
| 65 | const userConfig = require(configPath); |
| 66 | |
| 67 | // 合并默认配置和用户配置 |
| 68 | return deepMerge(defaultConfig, userConfig); |
| 69 | } |
| 70 | |
| 71 | // 如果配置文件不存在,返回默认配置 |
| 72 | logger.info('使用默认配置'); |
| 73 | return defaultConfig; |
| 74 | } catch (err) { |
| 75 | logger.error('加载配置文件时出错:', err); |
| 76 | logger.warn('使用默认配置'); |
| 77 | return defaultConfig; |
| 78 | } |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * 深度合并对象 |
no test coverage detected