fix(paths): update legacy config filenames to use resolved state directory

This commit is contained in:
Aditya Mer 2026-01-30 14:54:45 +05:30
parent a81e079d76
commit 92eae97961
2 changed files with 8 additions and 5 deletions

View File

@ -55,11 +55,12 @@ describe("state + config path candidates", () => {
it("returns legacy filenames when state dir override is set", () => {
const env = { OPENCLAW_STATE_DIR: "/custom/state" } as NodeJS.ProcessEnv;
const candidates = resolveDefaultConfigCandidates(env, () => "/home/test");
const base = path.resolve("/custom/state");
expect(candidates).toEqual([
"/custom/state/openclaw.json",
"/custom/state/clawdbot.json",
"/custom/state/moltbot.json",
"/custom/state/moldbot.json",
path.join(base, "openclaw.json"),
path.join(base, "clawdbot.json"),
path.join(base, "moltbot.json"),
path.join(base, "moldbot.json"),
]);
});

View File

@ -164,7 +164,9 @@ export function resolveDefaultConfigCandidates(
const resolved = resolveUserPath(openclawStateDir);
return [
path.join(resolved, CONFIG_FILENAME),
...LEGACY_CONFIG_FILENAMES.map((name) => path.join(resolved, name)),
path.join(resolved, "clawdbot.json"),
path.join(resolved, "moltbot.json"),
path.join(resolved, "moldbot.json"),
];
}