

















@@ -12,6 +12,7 @@ import os from "node:os";
1212import path from "node:path";
1313import { pipeline } from "node:stream/promises";
1414import { fileURLToPath } from "node:url";
15+import { resolveNpmRunner } from "./npm-runner.mjs";
15161617const ROOT_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
1718const DEFAULT_OUTPUT_NAME = "openclaw-current.tgz";
@@ -110,11 +111,38 @@ export function validateOpenClawPackageSpec(spec) {
110111}
111112}
112113114+export function resolveNpmPackageCandidatePackRunner(packageSpec, outputDir, params = {}) {
115+validateOpenClawPackageSpec(packageSpec);
116+return resolveNpmRunner({
117+comSpec: params.comSpec,
118+env: params.env,
119+execPath: params.execPath,
120+existsSync: params.existsSync,
121+npmArgs: [
122+"pack",
123+packageSpec,
124+"--ignore-scripts",
125+"--json",
126+"--pack-destination",
127+outputDir,
128+],
129+platform: params.platform,
130+});
131+}
132+113133function run(command, args, options = {}) {
114134return new Promise((resolve, reject) => {
115-const child = spawn(command, args, {
135+const spawnOptions = {
116136cwd: options.cwd ?? ROOT_DIR,
117137stdio: options.capture ? ["ignore", "pipe", "pipe"] : ["ignore", "inherit", "inherit"],
138+ ...(options.env ? { env: options.env } : {}),
139+ ...(options.shell !== undefined ? { shell: options.shell } : {}),
140+ ...(options.windowsVerbatimArguments !== undefined
141+ ? { windowsVerbatimArguments: options.windowsVerbatimArguments }
142+ : {}),
143+};
144+const child = spawn(command, args, {
145+ ...spawnOptions,
118146});
119147let timedOut = false;
120148const timeout =
@@ -1006,19 +1034,15 @@ async function resolveCandidate(options) {
10061034options.outputName || DEFAULT_OUTPUT_NAME,
10071035]);
10081036} else if (options.source === "npm") {
1009-validateOpenClawPackageSpec(options.packageSpec);
1010-const packOutput = await run(
1011-"npm",
1012-[
1013-"pack",
1014-options.packageSpec,
1015-"--ignore-scripts",
1016-"--json",
1017-"--pack-destination",
1018-outputDir,
1019-],
1020-{ capture: true },
1021-);
1037+const npmPackRunner = resolveNpmPackageCandidatePackRunner(options.packageSpec, outputDir, {
1038+env: process.env,
1039+});
1040+const packOutput = await run(npmPackRunner.command, npmPackRunner.args, {
1041+capture: true,
1042+env: npmPackRunner.env,
1043+shell: npmPackRunner.shell,
1044+windowsVerbatimArguments: npmPackRunner.windowsVerbatimArguments,
1045+});
10221046await moveNewestPackedTarball(
10231047outputDir,
10241048packOutput,
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。