
























@@ -5,6 +5,7 @@ import path from "node:path";
55import { bundledPluginRootAt } from "openclaw/plugin-sdk/test-fixtures";
66import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
77import type { OpenClawConfig } from "../config/config.js";
8+import { withEnvAsync } from "../test-utils/env.js";
89import type { PluginNpmIntegrityDriftParams } from "./install.js";
9101011const APP_ROOT = "/app";
@@ -1774,7 +1775,6 @@ describe("updateNpmInstalledPlugins", () => {
17741775path.join(installPath, "package.json"),
17751776JSON.stringify({ name: "@martian-engineering/lossless-claw", version: "0.9.0" }),
17761777);
1777-vi.stubEnv("HOME", home);
17781778mockNpmViewMetadata({
17791779name: "@martian-engineering/lossless-claw",
17801780version: "0.9.0",
@@ -1783,19 +1783,21 @@ describe("updateNpmInstalledPlugins", () => {
17831783});
17841784installPluginFromNpmSpecMock.mockRejectedValue(new Error("installer should not run"));
178517851786-const result = await updateNpmInstalledPlugins({
1787-config: createNpmInstallConfig({
1788-pluginId: "lossless-claw",
1789-spec: "@martian-engineering/lossless-claw",
1790-installPath: "~/.openclaw/extensions/lossless-claw",
1791-resolvedName: "@martian-engineering/lossless-claw",
1792-resolvedVersion: "0.9.0",
1793-resolvedSpec: "@martian-engineering/lossless-claw@0.9.0",
1794-integrity: "sha512-same",
1795-shasum: "same",
1786+const result = await withEnvAsync({ HOME: home }, () =>
1787+updateNpmInstalledPlugins({
1788+config: createNpmInstallConfig({
1789+pluginId: "lossless-claw",
1790+spec: "@martian-engineering/lossless-claw",
1791+installPath: "~/.openclaw/extensions/lossless-claw",
1792+resolvedName: "@martian-engineering/lossless-claw",
1793+resolvedVersion: "0.9.0",
1794+resolvedSpec: "@martian-engineering/lossless-claw@0.9.0",
1795+integrity: "sha512-same",
1796+shasum: "same",
1797+}),
1798+pluginIds: ["lossless-claw"],
17961799}),
1797-pluginIds: ["lossless-claw"],
1798-});
1800+);
1799180118001802expect(installPluginFromNpmSpecMock).not.toHaveBeenCalled();
18011803expect(result.changed).toBe(false);
@@ -3990,9 +3992,7 @@ describe("syncPluginsForUpdateChannel", () => {
39903992}),
39913993);
399239943993-const previousHome = process.env.HOME;
3994-process.env.HOME = "/tmp/process-home";
3995-try {
3995+await withEnvAsync({ HOME: "/tmp/process-home" }, async () => {
39963996const result = await syncPluginsForUpdateChannel({
39973997channel: "beta",
39983998env: {
@@ -4022,13 +4022,7 @@ describe("syncPluginsForUpdateChannel", () => {
40224022sourcePath: "~/plugins/feishu",
40234023installPath: "~/plugins/feishu",
40244024});
4025-} finally {
4026-if (previousHome === undefined) {
4027-delete process.env.HOME;
4028-} else {
4029-process.env.HOME = previousHome;
4030-}
4031-}
4025+});
40324026});
4033402740344028it("installs an externalized bundled plugin and rewrites its old bundled path plugin index", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。