Skip to content

Commit bfb227e

Browse files
authored
fix: tolerate legacy config filenames (moltbot/clawdbot) (#70)
1 parent 51811fa commit bfb227e

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

src/server.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,34 @@ function clawArgs(args) {
100100
return [OPENCLAW_ENTRY, ...args];
101101
}
102102

103+
function resolveConfigCandidates() {
104+
const explicit = getEnvWithShim("OPENCLAW_CONFIG_PATH", "CLAWDBOT_CONFIG_PATH");
105+
if (explicit) return [explicit];
106+
107+
// Prefer the newest canonical name, but fall back to legacy filenames if present.
108+
return [
109+
path.join(STATE_DIR, "openclaw.json"),
110+
path.join(STATE_DIR, "moltbot.json"),
111+
path.join(STATE_DIR, "clawdbot.json"),
112+
];
113+
}
114+
103115
function configPath() {
104-
return (
105-
getEnvWithShim("OPENCLAW_CONFIG_PATH", "CLAWDBOT_CONFIG_PATH") ||
106-
path.join(STATE_DIR, "openclaw.json")
107-
);
116+
const candidates = resolveConfigCandidates();
117+
for (const candidate of candidates) {
118+
try {
119+
if (fs.existsSync(candidate)) return candidate;
120+
} catch {
121+
// ignore
122+
}
123+
}
124+
// Default to canonical even if it doesn't exist yet.
125+
return candidates[0] || path.join(STATE_DIR, "openclaw.json");
108126
}
109127

110128
function isConfigured() {
111129
try {
112-
return fs.existsSync(configPath());
130+
return resolveConfigCandidates().some((candidate) => fs.existsSync(candidate));
113131
} catch {
114132
return false;
115133
}

0 commit comments

Comments
 (0)