Plugins: fix env-aware root resolution and caching (#44046)

Merged via squash.

Prepared head SHA: 6e8852a188
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
This commit is contained in:
Gustavo Madeira Santana
2026-03-12 15:31:31 +00:00
committed by GitHub
parent 688e3f0863
commit e6897c800b
29 changed files with 1423 additions and 151 deletions

View File

@@ -127,6 +127,15 @@ describe("resolveConfigDir", () => {
await fs.promises.rm(root, { recursive: true, force: true });
}
});
it("expands OPENCLAW_STATE_DIR using the provided env", () => {
const env = {
HOME: "/tmp/openclaw-home",
OPENCLAW_STATE_DIR: "~/state",
} as NodeJS.ProcessEnv;
expect(resolveConfigDir(env)).toBe(path.resolve("/tmp/openclaw-home", "state"));
});
});
describe("resolveHomeDir", () => {
@@ -214,6 +223,15 @@ describe("resolveUserPath", () => {
vi.unstubAllEnvs();
});
it("uses the provided env for tilde expansion", () => {
const env = {
HOME: "/tmp/openclaw-home",
OPENCLAW_HOME: "/srv/openclaw-home",
} as NodeJS.ProcessEnv;
expect(resolveUserPath("~/openclaw", env)).toBe(path.resolve("/srv/openclaw-home", "openclaw"));
});
it("keeps blank paths blank", () => {
expect(resolveUserPath("")).toBe("");
expect(resolveUserPath(" ")).toBe("");