* Check if a command is available in the system PATH. * Inherits enriched PATH from process.env (set by initShellEnv at startup).
(command: string)
| 152 | * Inherits enriched PATH from process.env (set by initShellEnv at startup). |
| 153 | */ |
| 154 | private async isCommandAvailable(command: string): Promise<boolean> { |
| 155 | try { |
| 156 | if (looksLikePath(command)) { |
| 157 | await fsPromises.access(command); |
| 158 | return true; |
| 159 | } |
| 160 | |
| 161 | const lookupCommand = process.platform === "win32" ? "where" : "which"; |
| 162 | const result = spawnSync(lookupCommand, [command], { encoding: "utf8" }); |
| 163 | return result.status === 0; |
| 164 | } catch { |
| 165 | return false; |
| 166 | } |
| 167 | } |
| 168 | } |
no test coverage detected