Fix Windows default shell for terminal creation

This commit is contained in:
Mohamed Boudra
2026-04-01 17:25:41 +07:00
parent 58d72bea87
commit cb60f2a596
2 changed files with 32 additions and 2 deletions
@@ -2,6 +2,7 @@ import { describe, it, expect, afterEach } from "vitest";
import {
createTerminal,
ensureNodePtySpawnHelperExecutableForCurrentPlatform,
resolveDefaultTerminalShell,
type TerminalSession,
} from "./terminal.js";
import { chmodSync, mkdtempSync, mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
@@ -111,6 +112,18 @@ describe("Terminal", () => {
expect(statSync(helperPath).mode & 0o111).toBe(0o111);
});
it("uses cmd.exe-compatible default shell on Windows", () => {
expect(resolveDefaultTerminalShell({ platform: "win32", env: {} })).toBe(
"C:\\Windows\\System32\\cmd.exe",
);
expect(
resolveDefaultTerminalShell({
platform: "win32",
env: { ComSpec: "C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe" },
}),
).toBe("C:\\Windows\\System32\\WindowsPowerShell\\v1.0\\powershell.exe");
});
it("creates a terminal session with an id, name, and cwd", async () => {
const session = trackSession(
await createTerminal({