(command: string)
| 64 | |
| 65 | // Helper function to use login shell on Unix/macOS and PowerShell on Windows and available shell in WSL |
| 66 | function getShellCommand(command: string): { shell: string; args: string[] } { |
| 67 | if (process.platform === "win32") { |
| 68 | // Windows: Use PowerShell |
| 69 | return { |
| 70 | shell: "powershell.exe", |
| 71 | args: ["-NoLogo", "-ExecutionPolicy", "Bypass", "-Command", command], |
| 72 | }; |
| 73 | } |
| 74 | |
| 75 | if (isRunningInWsl()) { |
| 76 | // in WSL, bash is always available |
| 77 | const wslShell = process.env.SHELL || "/bin/bash"; |
| 78 | return { |
| 79 | shell: wslShell, |
| 80 | args: ["-l", "-c", command], |
| 81 | }; |
| 82 | } |
| 83 | |
| 84 | // Unix/macOS: Use login shell to source .bashrc/.zshrc etc. |
| 85 | const userShell = process.env.SHELL || "/bin/bash"; |
| 86 | return { shell: userShell, args: ["-l", "-c", command] }; |
| 87 | } |
| 88 | |
| 89 | export function runCommandInBackground(command: string): { |
| 90 | success: boolean; |
no test coverage detected