mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 04:47:03 -06:00
fix(scripts): run npm cli with active node
This commit is contained in:
@@ -11,10 +11,7 @@ function resolveToolchainNpmRunner(params) {
|
||||
const npmCliPath = npmCliCandidates.find((candidate) => params.existsSync(candidate));
|
||||
if (npmCliPath) {
|
||||
return {
|
||||
command:
|
||||
params.platform === "win32"
|
||||
? params.pathImpl.join(params.nodeDir, "node.exe")
|
||||
: params.pathImpl.join(params.nodeDir, "node"),
|
||||
command: params.execPath,
|
||||
args: [npmCliPath, ...params.npmArgs],
|
||||
shell: false,
|
||||
};
|
||||
@@ -57,6 +54,7 @@ export function resolveNpmRunner(params = {}) {
|
||||
const npmToolchain = resolveToolchainNpmRunner({
|
||||
comSpec,
|
||||
existsSync,
|
||||
execPath,
|
||||
nodeDir,
|
||||
npmArgs,
|
||||
pathImpl,
|
||||
|
||||
@@ -25,6 +25,28 @@ describe("resolveNpmRunner", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("uses the active node executable when its basename is not node", () => {
|
||||
const execPath = "/Users/test/.toolchains/node-24/bin/node24";
|
||||
const expectedNpmCliPath = path.posix.resolve(
|
||||
path.posix.dirname(execPath),
|
||||
"../lib/node_modules/npm/bin/npm-cli.js",
|
||||
);
|
||||
|
||||
const runner = resolveNpmRunner({
|
||||
execPath,
|
||||
env: {},
|
||||
existsSync: (candidate) => candidate === expectedNpmCliPath,
|
||||
npmArgs: ["pack", "openclaw@beta"],
|
||||
platform: "darwin",
|
||||
});
|
||||
|
||||
expect(runner).toEqual({
|
||||
command: execPath,
|
||||
args: [expectedNpmCliPath, "pack", "openclaw@beta"],
|
||||
shell: false,
|
||||
});
|
||||
});
|
||||
|
||||
it("anchors Windows npm staging to the adjacent npm-cli.js without a shell", () => {
|
||||
const execPath = "C:\\nodejs\\node.exe";
|
||||
const expectedNpmCliPath = path.win32.resolve(
|
||||
|
||||
Reference in New Issue
Block a user