mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 17:20:42 +00:00
fix(update): skip package no-op installs
This commit is contained in:
@@ -837,6 +837,33 @@ describe("update-cli", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("skips package-manager updates when the installed version already matches the target", async () => {
|
||||
const tempDir = createCaseDir("openclaw-update");
|
||||
mockPackageInstallStatus(tempDir);
|
||||
readPackageVersion.mockResolvedValue("2026.4.22");
|
||||
vi.mocked(resolveNpmChannelTag).mockResolvedValue({
|
||||
tag: "latest",
|
||||
version: "2026.4.22",
|
||||
});
|
||||
|
||||
await updateCommand({ yes: true });
|
||||
|
||||
const installCalls = vi
|
||||
.mocked(runCommandWithTimeout)
|
||||
.mock.calls.filter(
|
||||
([argv]) => Array.isArray(argv) && argv[0] === "npm" && argv[1] === "i" && argv[2] === "-g",
|
||||
);
|
||||
expect(installCalls).toEqual([]);
|
||||
expect(syncPluginsForUpdateChannel).not.toHaveBeenCalled();
|
||||
expect(updateNpmInstalledPlugins).not.toHaveBeenCalled();
|
||||
expect(replaceConfigFile).not.toHaveBeenCalled();
|
||||
expect(runRestartScript).not.toHaveBeenCalled();
|
||||
expect(runDaemonRestart).not.toHaveBeenCalled();
|
||||
expect(defaultRuntime.exit).toHaveBeenCalledWith(0);
|
||||
const logs = vi.mocked(defaultRuntime.log).mock.calls.map((call) => String(call[0]));
|
||||
expect(logs.join("\n")).toContain("already-current");
|
||||
});
|
||||
|
||||
it("blocks package updates when the target requires a newer Node runtime", async () => {
|
||||
mockPackageInstallStatus(createCaseDir("openclaw-update"));
|
||||
vi.mocked(fetchNpmPackageTargetStatus).mockResolvedValue({
|
||||
|
||||
Reference in New Issue
Block a user