Fix updater refresh cwd for service reinstall (#45452)
* Fix updater refresh cwd for service reinstall * Update: preserve relative env overrides during service refresh * Test: cover updater service refresh env rebasing
This commit is contained in:
@@ -624,12 +624,50 @@ describe("update-cli", () => {
|
||||
|
||||
expect(runCommandWithTimeout).toHaveBeenCalledWith(
|
||||
[expect.stringMatching(/node/), entryPath, "gateway", "install", "--force"],
|
||||
expect.objectContaining({ timeoutMs: 60_000 }),
|
||||
expect.objectContaining({ cwd: root, timeoutMs: 60_000 }),
|
||||
);
|
||||
expect(runDaemonInstall).not.toHaveBeenCalled();
|
||||
expect(runRestartScript).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("updateCommand preserves invocation-relative service env overrides during refresh", async () => {
|
||||
const root = createCaseDir("openclaw-updated-root");
|
||||
const entryPath = path.join(root, "dist", "entry.js");
|
||||
pathExists.mockImplementation(async (candidate: string) => candidate === entryPath);
|
||||
|
||||
vi.mocked(runGatewayUpdate).mockResolvedValue({
|
||||
status: "ok",
|
||||
mode: "npm",
|
||||
root,
|
||||
steps: [],
|
||||
durationMs: 100,
|
||||
});
|
||||
serviceLoaded.mockResolvedValue(true);
|
||||
|
||||
await withEnvAsync(
|
||||
{
|
||||
OPENCLAW_STATE_DIR: "./state",
|
||||
OPENCLAW_CONFIG_PATH: "./config/openclaw.json",
|
||||
},
|
||||
async () => {
|
||||
await updateCommand({});
|
||||
},
|
||||
);
|
||||
|
||||
expect(runCommandWithTimeout).toHaveBeenCalledWith(
|
||||
[expect.stringMatching(/node/), entryPath, "gateway", "install", "--force"],
|
||||
expect.objectContaining({
|
||||
cwd: root,
|
||||
env: expect.objectContaining({
|
||||
OPENCLAW_STATE_DIR: path.resolve("./state"),
|
||||
OPENCLAW_CONFIG_PATH: path.resolve("./config/openclaw.json"),
|
||||
}),
|
||||
timeoutMs: 60_000,
|
||||
}),
|
||||
);
|
||||
expect(runDaemonInstall).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("updateCommand falls back to restart when env refresh install fails", async () => {
|
||||
await runRestartFallbackScenario({ daemonInstall: "fail" });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user