






















@@ -273,6 +273,7 @@ describe("updateNpmInstalledPlugins", () => {
273273});
274274275275afterEach(() => {
276+vi.unstubAllEnvs();
276277for (const dir of tempDirs.splice(0)) {
277278fs.rmSync(dir, { recursive: true, force: true });
278279}
@@ -410,6 +411,47 @@ describe("updateNpmInstalledPlugins", () => {
410411]);
411412});
412413414+it("expands home-relative install paths before checking installed npm versions", async () => {
415+const home = fs.mkdtempSync(path.join(os.tmpdir(), "openclaw-plugin-update-home-"));
416+tempDirs.push(home);
417+const installPath = path.join(home, ".openclaw", "extensions", "lossless-claw");
418+fs.mkdirSync(installPath, { recursive: true });
419+fs.writeFileSync(
420+path.join(installPath, "package.json"),
421+JSON.stringify({ name: "@martian-engineering/lossless-claw", version: "0.9.0" }),
422+);
423+vi.stubEnv("HOME", home);
424+mockNpmViewMetadata({
425+name: "@martian-engineering/lossless-claw",
426+version: "0.9.0",
427+integrity: "sha512-same",
428+shasum: "same",
429+});
430+installPluginFromNpmSpecMock.mockRejectedValue(new Error("installer should not run"));
431+432+const result = await updateNpmInstalledPlugins({
433+config: createNpmInstallConfig({
434+pluginId: "lossless-claw",
435+spec: "@martian-engineering/lossless-claw",
436+installPath: "~/.openclaw/extensions/lossless-claw",
437+resolvedName: "@martian-engineering/lossless-claw",
438+resolvedSpec: "@martian-engineering/lossless-claw@0.9.0",
439+integrity: "sha512-same",
440+}),
441+pluginIds: ["lossless-claw"],
442+});
443+444+expect(installPluginFromNpmSpecMock).not.toHaveBeenCalled();
445+expect(result.changed).toBe(false);
446+expect(result.outcomes).toEqual([
447+expect.objectContaining({
448+pluginId: "lossless-claw",
449+status: "unchanged",
450+currentVersion: "0.9.0",
451+}),
452+]);
453+});
454+413455it("falls through to npm reinstall when the recorded integrity differs", async () => {
414456const installPath = createInstalledPackageDir({
415457name: "@martian-engineering/lossless-claw",
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。