

























@@ -55,6 +55,20 @@ function runEnsureNode(root: string, requested: string, extraEnv: NodeJS.Process
5555return result;
5656}
575758+function runVersionMatch(actual: string, requested: string) {
59+return spawnSync(
60+"bash",
61+[
62+"-c",
63+[
64+`source "${ensureNodeScript}"`,
65+`openclaw_node_version_matches "${actual}" "${requested}"`,
66+].join("; "),
67+],
68+{ encoding: "utf8", env: process.env },
69+);
70+}
71+5872describe("setup-pnpm-store-cache ensure-node", () => {
5973it("uses a matching active node", () => {
6074const root = mkdtempSync(join(tmpdir(), "openclaw-ensure-node-"));
@@ -186,6 +200,31 @@ exit 1
186200}
187201});
188202203+it("keeps the Node 22 wildcard at the supported minimum", () => {
204+const root = mkdtempSync(join(tmpdir(), "openclaw-ensure-node-"));
205+try {
206+const activeBin = join(root, "active", "bin");
207+writeFakeNode(activeBin, "22.18.0");
208+const toolcacheBin = join(root, "toolcache", "node", "22.22.3", "x64", "bin");
209+const toolcacheNode = writeFakeNode(toolcacheBin, "22.22.3");
210+const result = runEnsureNode(root, "22.x", {
211+PATH: `${activeBin}:${process.env.PATH ?? ""}`,
212+RUNNER_TOOL_CACHE: join(root, "toolcache"),
213+});
214+215+expect(result.status).toBe(0);
216+expect(result.stdout).toContain(`Using Node 22.22.3 from ${toolcacheNode}`);
217+expect(result.stdout.trim().endsWith("22.22.3")).toBe(true);
218+} finally {
219+rmSync(root, { recursive: true, force: true });
220+}
221+});
222+223+it("rejects Node 22 wildcard matches below the supported minimum", () => {
224+expect(runVersionMatch("22.18.0", "22.x").status).toBe(1);
225+expect(runVersionMatch("22.19.0", "22.x").status).toBe(0);
226+});
227+189228it("fails clearly when no matching node is available", () => {
190229const root = mkdtempSync(join(tmpdir(), "openclaw-ensure-node-"));
191230try {
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。