import { cmdCall } from "./cmdCall" import { cmdEnv } from "./cmdEnv" import { cmdExpectCommandOutput } from "./expect-command-output" import { cmdHasOutputContains } from "./output-contains" import { redirectOutput } from "./redirect-output" import { cmdInSubShell } from "./sub-shell" import { define, Shell } from "./types" export const Bash = { ...define({ binaryName: () => "bash", currentlySupported: () => true, name: () => "Bash", launchArgs: () => ["-i"], escapeText: (x) => x, dieOnErrors: () => `set -e`, }), ...cmdEnv.bash, ...cmdCall.all, ...redirectOutput.bash, ...cmdExpectCommandOutput.bash, ...cmdHasOutputContains.bash, ...cmdInSubShell.bash, } export const Zsh = { ...define({ binaryName: () => "zsh", currentlySupported: () => process.platform !== "win32", name: () => "Zsh", launchArgs: () => [], escapeText: (x) => x, dieOnErrors: () => `set -e`, }), ...cmdEnv.bash, ...cmdCall.all, ...cmdExpectCommandOutput.bash, ...cmdHasOutputContains.bash, ...cmdInSubShell.zsh, } export const Fish = { ...define({ binaryName: () => "fish", currentlySupported: () => process.platform !== "win32", name: () => "Fish", launchArgs: () => [], escapeText: (x) => x, forceFile: true, }), ...cmdEnv.fish, ...cmdCall.all, ...redirectOutput.bash, ...cmdExpectCommandOutput.fish, ...cmdHasOutputContains.fish, ...cmdInSubShell.fish, } export const PowerShell = { ...define({ binaryName: () => { if (process.platform === "win32") { return "powershell.exe" } else { return "pwsh" } }, forceFile: true, currentlySupported: () => true, name: () => "PowerShell", launchArgs: () => ["-NoProfile"], escapeText: (x) => x, dieOnErrors: () => `$ErrorActionPreference = "Stop"`, }), ...cmdEnv.powershell, ...cmdCall.all, ...cmdExpectCommandOutput.powershell, ...cmdHasOutputContains.powershell, ...cmdInSubShell.powershell, } export const WinCmd = { ...define({ binaryName: () => "cmd.exe", currentlySupported: () => process.platform === "win32", name: () => "Windows Command Prompt", launchArgs: () => [], escapeText: (str) => str .replace(/\r/g, "") .replace(/\n/g, "^\n\n") .replace(/\%/g, "%%") .replace(/\|/g, "^|") .replace(/\(/g, "^(") .replace(/\)/g, "^)"), }), ...cmdEnv.wincmd, ...cmdCall.all, ...cmdExpectCommandOutput.wincmd, }