






















@@ -158,6 +158,63 @@ describe("install-cli.sh", () => {
158158expect(script).toContain('activate_repo_pnpm_version "$repo_dir"');
159159});
160160161+it("uses the repo Corepack pnpm when a global pnpm version is already present", () => {
162+const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-cli-pnpm-version-"));
163+const bin = join(tmp, "bin");
164+const outer = join(tmp, "outer");
165+const repo = join(tmp, "repo");
166+mkdirSync(bin, { recursive: true });
167+mkdirSync(outer, { recursive: true });
168+mkdirSync(repo, { recursive: true });
169+writeFileSync(
170+join(outer, "package.json"),
171+'{\n "packageManager": "yarn@4.5.0"\n}\n',
172+);
173+writeFileSync(
174+join(repo, "package.json"),
175+'{\n "packageManager": "pnpm@11.2.2+sha512.test"\n}\n',
176+);
177+writeFileSync(
178+join(bin, "pnpm"),
179+["#!/bin/bash", '[[ "${1:-}" == "--version" ]] && echo "11.8.0"', ""].join("\n"),
180+);
181+writeFileSync(
182+join(bin, "corepack"),
183+[
184+"#!/bin/bash",
185+'if [[ "${1:-}" == "prepare" ]]; then exit 0; fi',
186+'if [[ "${1:-}" == "pnpm" && "${2:-}" == "--version" ]]; then',
187+' if grep -q "pnpm@11.2.2" package.json 2>/dev/null; then echo "11.2.2"; else exit 1; fi',
188+" exit 0",
189+"fi",
190+"exit 1",
191+"",
192+].join("\n"),
193+);
194+chmodSync(join(bin, "pnpm"), 0o755);
195+chmodSync(join(bin, "corepack"), 0o755);
196+197+try {
198+const result = runInstallCliShell(
199+[
200+`cd ${JSON.stringify(process.cwd())}`,
201+`source ${JSON.stringify(SCRIPT_PATH)}`,
202+`cd ${JSON.stringify(outer)}`,
203+`activate_repo_pnpm_version ${JSON.stringify(repo)}`,
204+'printf "cmd=%s\\n" "${PNPM_CMD[*]}"',
205+`printf "run=%s\\n" "$(run_pnpm -C ${JSON.stringify(repo)} --version)"`,
206+].join("\n"),
207+{ PATH: `${bin}:${process.env.PATH ?? ""}` },
208+);
209+210+expect(result.status).toBe(0);
211+expect(result.stdout).toContain(`cmd=${join(bin, "corepack")} pnpm`);
212+expect(result.stdout).toContain("run=11.2.2");
213+} finally {
214+rmSync(tmp, { force: true, recursive: true });
215+}
216+});
217+161218it("links an existing usable Alpine/musl Node runtime without sudo", () => {
162219const tmp = mkdtempSync(join(tmpdir(), "openclaw-install-cli-alpine-"));
163220const bin = join(tmp, "bin");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。