Merge 949f703e81 into 4583f88626
This commit is contained in:
commit
b51bafc098
@ -34,4 +34,23 @@ describe("resolveGatewayStateDir", () => {
|
|||||||
const env = { CLAWDBOT_STATE_DIR: "C:\\State\\moltbot" };
|
const env = { CLAWDBOT_STATE_DIR: "C:\\State\\moltbot" };
|
||||||
expect(resolveGatewayStateDir(env)).toBe("C:\\State\\moltbot");
|
expect(resolveGatewayStateDir(env)).toBe("C:\\State\\moltbot");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("uses MOLTBOT_STATE_DIR when provided", () => {
|
||||||
|
const env = { HOME: "/Users/test", MOLTBOT_STATE_DIR: "/var/lib/moltbot" };
|
||||||
|
expect(resolveGatewayStateDir(env)).toBe(path.resolve("/var/lib/moltbot"));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("prefers MOLTBOT_STATE_DIR over CLAWDBOT_STATE_DIR", () => {
|
||||||
|
const env = {
|
||||||
|
HOME: "/Users/test",
|
||||||
|
MOLTBOT_STATE_DIR: "/var/lib/moltbot-new",
|
||||||
|
CLAWDBOT_STATE_DIR: "/var/lib/moltbot-old",
|
||||||
|
};
|
||||||
|
expect(resolveGatewayStateDir(env)).toBe(path.resolve("/var/lib/moltbot-new"));
|
||||||
|
});
|
||||||
|
|
||||||
|
it("expands ~ in MOLTBOT_STATE_DIR", () => {
|
||||||
|
const env = { HOME: "/Users/test", MOLTBOT_STATE_DIR: "~/.moltbot" };
|
||||||
|
expect(resolveGatewayStateDir(env)).toBe(path.resolve("/Users/test/.moltbot"));
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -26,7 +26,7 @@ export function resolveUserPathWithHome(input: string, home?: string): string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function resolveGatewayStateDir(env: Record<string, string | undefined>): string {
|
export function resolveGatewayStateDir(env: Record<string, string | undefined>): string {
|
||||||
const override = env.CLAWDBOT_STATE_DIR?.trim();
|
const override = env.MOLTBOT_STATE_DIR?.trim() || env.CLAWDBOT_STATE_DIR?.trim();
|
||||||
if (override) {
|
if (override) {
|
||||||
const home = override.startsWith("~") ? resolveHomeDir(env) : undefined;
|
const home = override.startsWith("~") ? resolveHomeDir(env) : undefined;
|
||||||
return resolveUserPathWithHome(override, home);
|
return resolveUserPathWithHome(override, home);
|
||||||
|
|||||||
@ -140,6 +140,7 @@ export function buildServiceEnvironment(params: {
|
|||||||
HOME: env.HOME,
|
HOME: env.HOME,
|
||||||
PATH: buildMinimalServicePath({ env }),
|
PATH: buildMinimalServicePath({ env }),
|
||||||
CLAWDBOT_PROFILE: profile,
|
CLAWDBOT_PROFILE: profile,
|
||||||
|
MOLTBOT_STATE_DIR: env.MOLTBOT_STATE_DIR,
|
||||||
CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR,
|
CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR,
|
||||||
CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH,
|
CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH,
|
||||||
CLAWDBOT_GATEWAY_PORT: String(port),
|
CLAWDBOT_GATEWAY_PORT: String(port),
|
||||||
@ -159,6 +160,7 @@ export function buildNodeServiceEnvironment(params: {
|
|||||||
return {
|
return {
|
||||||
HOME: env.HOME,
|
HOME: env.HOME,
|
||||||
PATH: buildMinimalServicePath({ env }),
|
PATH: buildMinimalServicePath({ env }),
|
||||||
|
MOLTBOT_STATE_DIR: env.MOLTBOT_STATE_DIR,
|
||||||
CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR,
|
CLAWDBOT_STATE_DIR: env.CLAWDBOT_STATE_DIR,
|
||||||
CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH,
|
CLAWDBOT_CONFIG_PATH: env.CLAWDBOT_CONFIG_PATH,
|
||||||
CLAWDBOT_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel(),
|
CLAWDBOT_LAUNCHD_LABEL: resolveNodeLaunchAgentLabel(),
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user