fix(scripts): run npm cli with active node · openclaw/openclaw@22f696d
vincentkoc
·
2026-06-20
·
via Recent Commits to openclaw:main
| Original file line number | Diff line number | Diff line change |
|---|
@@ -11,10 +11,7 @@ function resolveToolchainNpmRunner(params) {
|
11 | 11 | const npmCliPath = npmCliCandidates.find((candidate) => params.existsSync(candidate)); |
12 | 12 | if (npmCliPath) { |
13 | 13 | return { |
14 | | -command: |
15 | | -params.platform === "win32" |
16 | | - ? params.pathImpl.join(params.nodeDir, "node.exe") |
17 | | - : params.pathImpl.join(params.nodeDir, "node"), |
| 14 | +command: params.execPath, |
18 | 15 | args: [npmCliPath, ...params.npmArgs], |
19 | 16 | shell: false, |
20 | 17 | }; |
@@ -57,6 +54,7 @@ export function resolveNpmRunner(params = {}) {
|
57 | 54 | const npmToolchain = resolveToolchainNpmRunner({ |
58 | 55 | comSpec, |
59 | 56 | existsSync, |
| 57 | + execPath, |
60 | 58 | nodeDir, |
61 | 59 | npmArgs, |
62 | 60 | pathImpl, |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -25,6 +25,28 @@ describe("resolveNpmRunner", () => {
|
25 | 25 | }); |
26 | 26 | }); |
27 | 27 | |
| 28 | +it("uses the active node executable when its basename is not node", () => { |
| 29 | +const execPath = "/Users/test/.toolchains/node-24/bin/node24"; |
| 30 | +const expectedNpmCliPath = path.posix.resolve( |
| 31 | +path.posix.dirname(execPath), |
| 32 | +"../lib/node_modules/npm/bin/npm-cli.js", |
| 33 | +); |
| 34 | + |
| 35 | +const runner = resolveNpmRunner({ |
| 36 | + execPath, |
| 37 | +env: {}, |
| 38 | +existsSync: (candidate) => candidate === expectedNpmCliPath, |
| 39 | +npmArgs: ["pack", "openclaw@beta"], |
| 40 | +platform: "darwin", |
| 41 | +}); |
| 42 | + |
| 43 | +expect(runner).toEqual({ |
| 44 | +command: execPath, |
| 45 | +args: [expectedNpmCliPath, "pack", "openclaw@beta"], |
| 46 | +shell: false, |
| 47 | +}); |
| 48 | +}); |
| 49 | + |
28 | 50 | it("anchors Windows npm staging to the adjacent npm-cli.js without a shell", () => { |
29 | 51 | const execPath = "C:\\nodejs\\node.exe"; |
30 | 52 | const expectedNpmCliPath = path.win32.resolve( |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。