mirror of
https://github.com/openclaw/openclaw.git
synced 2026-06-06 05:51:15 +08:00
fix: honor OPENCLAW_HOME defaults (#85802)
* fix: honor OPENCLAW_HOME defaults * fix(install): preserve openclaw home upgrade defaults * fix(install): satisfy shellcheck tilde patterns
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { spawnSync } from "node:child_process";
|
||||
import { readFileSync } from "node:fs";
|
||||
import { mkdtempSync, mkdirSync, readFileSync, rmSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const SCRIPT_PATH = "scripts/install-cli.sh";
|
||||
@@ -18,6 +20,38 @@ function runInstallCliShell(script: string, env: NodeJS.ProcessEnv = {}) {
|
||||
describe("install-cli.sh", () => {
|
||||
const script = readFileSync(SCRIPT_PATH, "utf8");
|
||||
|
||||
it("keeps HOME for default prefix while OPENCLAW_HOME controls git checkout paths", () => {
|
||||
const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-cli-home-"));
|
||||
const osHome = join(tmp, "os-home");
|
||||
const openclawHome = join(tmp, "openclaw-home");
|
||||
mkdirSync(osHome, { recursive: true });
|
||||
mkdirSync(openclawHome, { recursive: true });
|
||||
|
||||
let result: ReturnType<typeof runInstallCliShell> | undefined;
|
||||
try {
|
||||
result = runInstallCliShell(
|
||||
[
|
||||
`cd ${JSON.stringify(process.cwd())}`,
|
||||
`source ${JSON.stringify(SCRIPT_PATH)}`,
|
||||
'printf "prefix=%s\\ngit=%s\\n" "$PREFIX" "$GIT_DIR"',
|
||||
].join("\n"),
|
||||
{
|
||||
HOME: osHome,
|
||||
OPENCLAW_HOME: openclawHome,
|
||||
OPENCLAW_GIT_DIR: undefined,
|
||||
OPENCLAW_PREFIX: undefined,
|
||||
},
|
||||
);
|
||||
} finally {
|
||||
rmSync(tmp, { force: true, recursive: true });
|
||||
}
|
||||
|
||||
expect(result?.status).toBe(0);
|
||||
const output = result?.stdout ?? "";
|
||||
expect(output).toContain(`prefix=${join(osHome, ".openclaw")}`);
|
||||
expect(output).toContain(`git=${join(openclawHome, "openclaw")}`);
|
||||
});
|
||||
|
||||
it("resolves requested git install versions to checkout refs", () => {
|
||||
const result = runInstallCliShell(`
|
||||
set -euo pipefail
|
||||
|
||||
Reference in New Issue
Block a user