






















@@ -13,7 +13,14 @@ import {
1313import { builtinModules } from "node:module";
1414import { createRequire } from "node:module";
1515import { tmpdir } from "node:os";
16-import { dirname, isAbsolute, join, relative } from "node:path";
16+import {
17+dirname,
18+isAbsolute,
19+join,
20+posix as pathPosix,
21+relative,
22+win32 as pathWin32,
23+} from "node:path";
1724import { pathToFileURL } from "node:url";
1825import { formatErrorMessage } from "../src/infra/errors.ts";
1926import { BUNDLED_RUNTIME_SIDECAR_PATHS } from "../src/plugins/runtime-sidecar-paths.ts";
@@ -24,6 +31,7 @@ import {
2431} from "./lib/plugin-package-dependencies.mjs";
2532import { runInstalledWorkspaceBootstrapSmoke } from "./lib/workspace-bootstrap-smoke.mjs";
2633import { parseReleaseVersion, resolveNpmCommandInvocation } from "./openclaw-npm-release-check.ts";
34+import { buildCmdExeCommandLine } from "./windows-cmd-helpers.mjs";
27352836type InstalledPackageJson = {
2937version?: string;
@@ -496,8 +504,33 @@ function isBundledExtensionOwnedRuntimeImport(params: {
496504497505export function resolveInstalledBinaryPath(prefixDir: string, platform = process.platform): string {
498506return platform === "win32"
499- ? join(prefixDir, "openclaw.cmd")
500- : join(prefixDir, "bin", "openclaw");
507+ ? pathWin32.join(prefixDir, "openclaw.cmd")
508+ : pathPosix.join(prefixDir, "bin", "openclaw");
509+}
510+511+export function resolveInstalledBinaryCommandInvocation(
512+prefixDir: string,
513+args: string[],
514+params: { comSpec?: string; platform?: NodeJS.Platform } = {},
515+): {
516+args: string[];
517+command: string;
518+windowsVerbatimArguments?: boolean;
519+} {
520+const platform = params.platform ?? process.platform;
521+const binaryPath = resolveInstalledBinaryPath(prefixDir, platform);
522+if (platform === "win32") {
523+return {
524+command: params.comSpec ?? process.env.ComSpec ?? "cmd.exe",
525+args: ["/d", "/s", "/c", buildCmdExeCommandLine(binaryPath, args)],
526+windowsVerbatimArguments: true,
527+};
528+}
529+530+return {
531+command: binaryPath,
532+ args,
533+};
501534}
502535503536function collectExpectedBundledExtensionPackageIds(): ReadonlySet<string> {
@@ -604,11 +637,12 @@ function installSpec(prefixDir: string, spec: string, cwd: string): void {
604637}
605638606639function readInstalledBinaryVersion(prefixDir: string, cwd: string): string {
607-return execFileSync(resolveInstalledBinaryPath(prefixDir), ["--version"], {
640+const invocation = resolveInstalledBinaryCommandInvocation(prefixDir, ["--version"]);
641+return execFileSync(invocation.command, invocation.args, {
608642 cwd,
609643encoding: "utf8",
610-shell: process.platform === "win32",
611644stdio: ["ignore", "pipe", "pipe"],
645+windowsVerbatimArguments: invocation.windowsVerbatimArguments,
612646}).trim();
613647}
614648此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。