mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-27 12:56:01 -06:00
fix(windows): resolve cmd handoff path
This commit is contained in:
@@ -4,6 +4,7 @@ import fs from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
||||
import { getWindowsCmdExePath } from "../../infra/windows-install-roots.js";
|
||||
import { prepareRestartScript, runRestartScript } from "./restart-helper.js";
|
||||
|
||||
vi.mock("node:child_process", async () => {
|
||||
@@ -616,7 +617,7 @@ exit 0
|
||||
|
||||
await runRestartScript(scriptPath);
|
||||
|
||||
expect(spawn).toHaveBeenCalledWith("cmd.exe", ["/d", "/s", "/c", scriptPath], {
|
||||
expect(spawn).toHaveBeenCalledWith(getWindowsCmdExePath(), ["/d", "/s", "/c", scriptPath], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
windowsHide: true,
|
||||
@@ -633,11 +634,15 @@ exit 0
|
||||
|
||||
await runRestartScript(scriptPath);
|
||||
|
||||
expect(spawn).toHaveBeenCalledWith("cmd.exe", ["/d", "/s", "/c", `"${scriptPath}"`], {
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
windowsHide: true,
|
||||
});
|
||||
expect(spawn).toHaveBeenCalledWith(
|
||||
getWindowsCmdExePath(),
|
||||
["/d", "/s", "/c", `"${scriptPath}"`],
|
||||
{
|
||||
detached: true,
|
||||
stdio: "ignore",
|
||||
windowsHide: true,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
it("does not throw when spawn fails synchronously", async () => {
|
||||
|
||||
@@ -16,6 +16,7 @@ import {
|
||||
resolveGatewayRestartLogPath,
|
||||
shellEscapeRestartLogValue,
|
||||
} from "../../daemon/restart-logs.js";
|
||||
import { getWindowsCmdExePath } from "../../infra/windows-install-roots.js";
|
||||
|
||||
/**
|
||||
* Shell-escape a string for embedding in single-quoted shell arguments.
|
||||
@@ -404,7 +405,7 @@ exit $status
|
||||
*/
|
||||
export async function runRestartScript(scriptPath: string): Promise<void> {
|
||||
const isWindows = process.platform === "win32";
|
||||
const file = isWindows ? "cmd.exe" : "/bin/sh";
|
||||
const file = isWindows ? getWindowsCmdExePath() : "/bin/sh";
|
||||
const args = isWindows ? ["/d", "/s", "/c", quoteCmdScriptArg(scriptPath)] : [scriptPath];
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user