

























@@ -1047,10 +1047,25 @@ describe("uninstallPlugin", () => {
10471047await expect(fs.lstat(peerLink).then((stat) => stat.isSymbolicLink())).resolves.toBe(true);
10481048});
104910491050-it("skips npm cleanup when the managed package directory is already absent", async () => {
1050+it("runs npm cleanup when the managed package directory is already absent", async () => {
10511051const stateDir = path.join(tempDir, "state");
10521052const npmRoot = path.join(stateDir, "npm");
10531053const pluginDir = path.join(npmRoot, "node_modules", "missing-plugin");
1054+const peerPluginDir = path.join(npmRoot, "node_modules", "peer-plugin");
1055+const peerLink = path.join(peerPluginDir, "node_modules", "openclaw");
1056+await fs.mkdir(peerLink, { recursive: true });
1057+await fs.writeFile(
1058+path.join(peerPluginDir, "package.json"),
1059+`${JSON.stringify(
1060+ {
1061+ name: "peer-plugin",
1062+ version: "1.0.0",
1063+ peerDependencies: { openclaw: ">=2026.0.0" },
1064+ },
1065+ null,
1066+ 2,
1067+ )}\n`,
1068+);
1054106910551070const applied = await applyPluginUninstallDirectoryRemoval({
10561071target: pluginDir,
@@ -1062,7 +1077,30 @@ describe("uninstallPlugin", () => {
10621077});
1063107810641079expect(applied).toEqual({ directoryRemoved: false, warnings: [] });
1065-expect(runCommandWithTimeoutMock).not.toHaveBeenCalled();
1080+expect(runCommandWithTimeoutMock).toHaveBeenCalledWith(
1081+[
1082+"npm",
1083+"uninstall",
1084+"--loglevel=error",
1085+"--legacy-peer-deps",
1086+"--ignore-scripts",
1087+"--no-audit",
1088+"--no-fund",
1089+"--prefix",
1090+".",
1091+"missing-plugin",
1092+],
1093+expect.objectContaining({
1094+cwd: npmRoot,
1095+timeoutMs: 300_000,
1096+env: expect.objectContaining({
1097+NPM_CONFIG_IGNORE_SCRIPTS: "true",
1098+npm_config_legacy_peer_deps: "true",
1099+npm_config_package_lock: "true",
1100+}),
1101+}),
1102+);
1103+await expect(fs.lstat(peerLink).then((stat) => stat.isSymbolicLink())).resolves.toBe(true);
10661104});
1067110510681106it("warns and still removes npm package dirs when npm prune cleanup fails", async () => {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。