( command: string, platform: NodeJS.Platform = process.platform, environment: NodeJS.ProcessEnv = process.env, )
| 33 | const POSIX_SHELLS = new Set(["ash", "dash", "sh"]); |
| 34 | |
| 35 | export function resolveShellCommand( |
| 36 | command: string, |
| 37 | platform: NodeJS.Platform = process.platform, |
| 38 | environment: NodeJS.ProcessEnv = process.env, |
| 39 | ): ShellCommand { |
| 40 | if (platform === "win32") { |
| 41 | return { |
| 42 | executable: environment.ComSpec ?? environment.COMSPEC ?? "cmd.exe", |
| 43 | args: ["/d", "/s", "/c", command], |
| 44 | }; |
| 45 | } |
| 46 | |
| 47 | const configuredShell = environment.SHELL; |
| 48 | const shellName = configuredShell ? basename(configuredShell) : ""; |
| 49 | if (configuredShell && LOGIN_SHELLS.has(shellName)) { |
| 50 | return { executable: configuredShell, args: ["-lc", command] }; |
| 51 | } |
| 52 | if (configuredShell && POSIX_SHELLS.has(shellName)) { |
| 53 | return { executable: configuredShell, args: ["-c", command] }; |
| 54 | } |
| 55 | |
| 56 | return { executable: "/bin/sh", args: ["-c", command] }; |
| 57 | } |
| 58 | |
| 59 | export function terminateProcessTree( |
| 60 | child: KillableProcess, |
no outgoing calls
no test coverage detected