



















@@ -104,6 +104,17 @@ function parseFakeCrabboxOutput(result: ReturnType<typeof runWrapper>): {
104104return JSON.parse(result.stdout.trim()) as { args: string[]; cwd: string };
105105}
106106107+function normalizeShellLineEndings(value: string): string {
108+return value.replace(/\r\n/g, "\n");
109+}
110+111+function expectGroupedShellCommand(remoteCommand: string, command: string): void {
112+expect(remoteCommand).toContain(`&& { ${command}`);
113+if (process.platform !== "win32") {
114+expect(remoteCommand).toContain(`${command}\n}`);
115+}
116+}
117+107118afterEach(() => {
108119for (const dir of tempDirs.splice(0)) {
109120rmSync(dir, { recursive: true, force: true });
@@ -215,7 +226,7 @@ describe("scripts/crabbox-wrapper", () => {
215226);
216227217228const output = parseFakeCrabboxOutput(result);
218-const remoteCommand = output.args.at(-1) ?? "";
229+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
219230expect(result.status).toBe(0);
220231expect(output.args).toContain("--shell");
221232expect(result.stderr).toContain(
@@ -228,7 +239,7 @@ describe("scripts/crabbox-wrapper", () => {
228239expect(remoteCommand).toContain('return "$status"');
229240expect(remoteCommand).toContain("node --version >&2");
230241expect(remoteCommand).toContain("pnpm --version >&2");
231-expect(remoteCommand).toContain("&& { pnpm --version\n}");
242+expectGroupedShellCommand(remoteCommand, "pnpm --version");
232243});
233244234245it("preserves shell commands when bootstrapping raw AWS macOS JavaScript commands", () => {
@@ -238,11 +249,11 @@ describe("scripts/crabbox-wrapper", () => {
238249);
239250240251const output = parseFakeCrabboxOutput(result);
241-const remoteCommand = output.args.at(-1) ?? "";
252+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
242253expect(result.status).toBe(0);
243254expect(output.args.filter((arg) => arg === "--shell")).toHaveLength(1);
244255expect(remoteCommand).toContain("openclaw_crabbox_bootstrap_macos_js");
245-expect(remoteCommand).toContain("&& { pnpm check:changed\n}");
256+expectGroupedShellCommand(remoteCommand, "pnpm check:changed");
246257});
247258248259it("groups shell commands so fallbacks cannot mask AWS macOS bootstrap failures", () => {
@@ -261,10 +272,10 @@ describe("scripts/crabbox-wrapper", () => {
261272);
262273263274const output = parseFakeCrabboxOutput(result);
264-const remoteCommand = output.args.at(-1) ?? "";
275+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
265276expect(result.status).toBe(0);
266-expect(remoteCommand).toContain("openclaw_crabbox_bootstrap_macos_js && {");
267-expect(remoteCommand).toContain("pnpm check:changed || true\n}");
277+expect(remoteCommand).toContain("openclaw_crabbox_bootstrap_macos_js");
278+expectGroupedShellCommand(remoteCommand, "pnpm check:changed || true");
268279});
269280270281it("does not bootstrap non-macOS AWS JavaScript commands", () => {
@@ -541,7 +552,7 @@ describe("scripts/crabbox-wrapper", () => {
541552);
542553543554const output = parseFakeCrabboxOutput(result);
544-const remoteCommand = output.args.at(-1) ?? "";
555+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
545556expect(result.status).toBe(0);
546557expect(output.args).toContain("--shell");
547558expect(remoteCommand).toContain("git init -q");
@@ -569,16 +580,14 @@ describe("scripts/crabbox-wrapper", () => {
569580);
570581571582const output = parseFakeCrabboxOutput(result);
572-const remoteCommand = output.args.at(-1) ?? "";
583+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
573584expect(result.status).toBe(0);
574585expect(output.args.filter((arg) => arg === "--shell")).toHaveLength(1);
575586expect(remoteCommand).toContain(
576587"git fetch -q --depth=1 origin abc123:refs/remotes/origin/main",
577588);
578589expect(remoteCommand).toContain("openclaw_crabbox_bootstrap_macos_js");
579-expect(remoteCommand).toContain(
580-"openclaw_crabbox_bootstrap_macos_js && { pnpm check:changed\n}",
581-);
590+expectGroupedShellCommand(remoteCommand, "pnpm check:changed");
582591});
583592584593it("preserves existing shell changed-gate commands after remote Git bootstrap", () => {
@@ -595,7 +604,7 @@ describe("scripts/crabbox-wrapper", () => {
595604);
596605597606const output = parseFakeCrabboxOutput(result);
598-const remoteCommand = output.args.at(-1) ?? "";
607+const remoteCommand = normalizeShellLineEndings(output.args.at(-1) ?? "");
599608expect(result.status).toBe(0);
600609expect(output.args.filter((arg) => arg === "--shell")).toHaveLength(1);
601610expect(remoteCommand).toContain(
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。