mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-28 18:33:37 +00:00
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { buildNodeShellCommand } from "./node-shell.js";
|
|
|
|
describe("buildNodeShellCommand", () => {
|
|
it("uses cmd.exe for win-prefixed platform labels", () => {
|
|
expect(buildNodeShellCommand("echo hi", "win32")).toEqual([
|
|
"cmd.exe",
|
|
"/d",
|
|
"/s",
|
|
"/c",
|
|
"echo hi",
|
|
]);
|
|
expect(buildNodeShellCommand("echo hi", "windows")).toEqual([
|
|
"cmd.exe",
|
|
"/d",
|
|
"/s",
|
|
"/c",
|
|
"echo hi",
|
|
]);
|
|
expect(buildNodeShellCommand("echo hi", " Windows 11 ")).toEqual([
|
|
"cmd.exe",
|
|
"/d",
|
|
"/s",
|
|
"/c",
|
|
"echo hi",
|
|
]);
|
|
});
|
|
|
|
it("uses /bin/sh for non-windows and missing platform values", () => {
|
|
expect(buildNodeShellCommand("echo hi", "darwin")).toEqual(["/bin/sh", "-lc", "echo hi"]);
|
|
expect(buildNodeShellCommand("echo hi", "linux")).toEqual(["/bin/sh", "-lc", "echo hi"]);
|
|
expect(buildNodeShellCommand("echo hi")).toEqual(["/bin/sh", "-lc", "echo hi"]);
|
|
expect(buildNodeShellCommand("echo hi", null)).toEqual(["/bin/sh", "-lc", "echo hi"]);
|
|
expect(buildNodeShellCommand("echo hi", " ")).toEqual(["/bin/sh", "-lc", "echo hi"]);
|
|
});
|
|
});
|