import { ChildProcess, spawn, spawnSync } from "child_process" import { existsSync, statSync } from "fs" import path from "path" import { EventBus } from "../events/bus" import { LogLevel, WorkspaceLogEntry } from "../api-types" import { Logger } from "../logger" export const WINDOWS_CMD_EXTENSIONS = new Set([".cmd", ".bat"]) export const WINDOWS_POWERSHELL_EXTENSIONS = new Set([".ps1"]) export function buildSpawnSpec(binaryPath: string, args: string[]) { if (process.platform !== "win32") { return { command: binaryPath, args, options: {} as const } } const extension = path.extname(binaryPath).toLowerCase() if (WINDOWS_CMD_EXTENSIONS.has(extension)) { const comspec = process.env.ComSpec || "cmd.exe" // cmd.exe requires the full command as a single string. // Using the ""