()
| 35 | * 读取用户配置 |
| 36 | */ |
| 37 | export function getUserConfig(): UserConfig { |
| 38 | try { |
| 39 | if (!existsSync(CONFIG_FILE_PATH)) { |
| 40 | return DEFAULT_USER_CONFIG; |
| 41 | } |
| 42 | |
| 43 | const configContent = readFileSync(CONFIG_FILE_PATH, 'utf-8'); |
| 44 | const config = JSON.parse(configContent) as UserConfig; |
| 45 | |
| 46 | // 确保配置完整 |
| 47 | return { |
| 48 | ...DEFAULT_USER_CONFIG, |
| 49 | ...config, |
| 50 | }; |
| 51 | } catch (error) { |
| 52 | console.warn(chalk.yellow('⚠️ 读取用户配置失败,使用默认配置')); |
| 53 | return DEFAULT_USER_CONFIG; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | /** |
| 58 | * 保存用户配置 |
no test coverage detected