zen-gitsync 2.10.11 → 2.10.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zen-gitsync",
3
- "version": "2.10.11",
3
+ "version": "2.10.13",
4
4
  "description": "一个 git 提交的工具",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/config.js CHANGED
@@ -53,12 +53,11 @@ function getCurrentProjectKey() {
53
53
 
54
54
  // 从磁盘读取原始配置对象
55
55
  async function readRawConfigFile() {
56
- try {
57
- const data = await fs.readFile(configPath, 'utf-8');
58
- return JSON.parse(data);
59
- } catch (_) {
60
- return null;
56
+ const state = await safeLoadRaw();
57
+ if (!state.ok) {
58
+ throw state.error;
61
59
  }
60
+ return state.obj;
62
61
  }
63
62
 
64
63
  // 将原始配置对象写回磁盘
@@ -98,7 +97,13 @@ async function safeLoadRaw() {
98
97
  // 异步读取配置文件
99
98
  async function loadConfig() {
100
99
  const key = getCurrentProjectKey();
101
- const raw = await readRawConfigFile();
100
+ let raw = null;
101
+ try {
102
+ raw = await readRawConfigFile();
103
+ } catch (err) {
104
+ const msg = err?.message ? String(err.message) : String(err);
105
+ throw new Error(`系统配置文件JSON格式错误,请修复后重试。\n文件: ${configPath}\n原因: ${msg}`);
106
+ }
102
107
  // 兼容旧版(全局扁平结构)
103
108
  if (raw && !raw.projects) {
104
109
  return { ...defaultConfig, ...raw };