yymaxapi 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/yymaxapi.js +12 -2
- package/package.json +1 -1
package/bin/yymaxapi.js
CHANGED
|
@@ -513,8 +513,18 @@ function getConfigPath() {
|
|
|
513
513
|
// ============ 配置读写 ============
|
|
514
514
|
function readConfig(configPath) {
|
|
515
515
|
if (fs.existsSync(configPath)) {
|
|
516
|
-
|
|
517
|
-
|
|
516
|
+
try {
|
|
517
|
+
const raw = fs.readFileSync(configPath, 'utf8').trim();
|
|
518
|
+
if (!raw || (!raw.startsWith('{') && !raw.startsWith('['))) {
|
|
519
|
+
console.log(chalk.yellow(`\n⚠ 配置文件格式异常,将重新创建: ${configPath}`));
|
|
520
|
+
return null;
|
|
521
|
+
}
|
|
522
|
+
return JSON5.parse(raw);
|
|
523
|
+
} catch (e) {
|
|
524
|
+
console.log(chalk.yellow(`\n⚠ 配置文件解析失败: ${e.message}`));
|
|
525
|
+
console.log(chalk.gray(` 文件: ${configPath}`));
|
|
526
|
+
return null;
|
|
527
|
+
}
|
|
518
528
|
}
|
|
519
529
|
return null;
|
|
520
530
|
}
|