toggle-oh-my 1.0.1 → 1.0.2
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/index.js +17 -11
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -31,27 +31,33 @@ function findConfig() {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
// user-level:
|
|
34
|
+
// user-level configs: check ALL known platform paths
|
|
35
35
|
const home = homedir();
|
|
36
36
|
const userCandidates = [
|
|
37
|
+
// Windows paths (opencode on Windows may use any of these)
|
|
37
38
|
join(home, '.config', 'opencode', 'opencode.jsonc'),
|
|
38
39
|
join(home, '.config', 'opencode', 'opencode.json'),
|
|
39
40
|
join(home, '.opencode.json'),
|
|
40
41
|
];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
42
|
+
// Windows: %APPDATA%/opencode/config.json
|
|
43
|
+
if (platform() === 'win32' && process.env.APPDATA) {
|
|
44
|
+
userCandidates.push(
|
|
45
|
+
join(process.env.APPDATA, 'opencode', 'config.json'),
|
|
46
|
+
join(process.env.APPDATA, 'opencode', 'opencode.jsonc'),
|
|
47
|
+
);
|
|
45
48
|
}
|
|
46
|
-
|
|
47
|
-
// Linux/macOS fallback: $XDG_CONFIG_HOME/opencode/opencode.jsonc
|
|
49
|
+
// Linux/macOS: $XDG_CONFIG_HOME
|
|
48
50
|
if (platform() !== 'win32') {
|
|
49
51
|
const xdg = process.env.XDG_CONFIG_HOME || join(home, '.config');
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
userCandidates.push(join(xdg, 'opencode', 'opencode.jsonc'));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
for (const fp of userCandidates) {
|
|
56
|
+
if (!existsSync(fp)) continue;
|
|
57
|
+
try {
|
|
52
58
|
const raw = readFileSync(fp, 'utf-8');
|
|
53
|
-
return { path: fp, raw, format: 'jsonc' };
|
|
54
|
-
}
|
|
59
|
+
return { path: fp, raw, format: fp.endsWith('.jsonc') ? 'jsonc' : 'json' };
|
|
60
|
+
} catch { /* permission issue, try next */ }
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
return null;
|