* Check if a command is available in PATH. * * Uses which to find the actual executable without executing it. * This is a security best practice to avoid executing arbitrary code * in untrusted directories. * * @param command - The command to check for * @returns True if the command exists an
(command: string)
| 19 | * @returns True if the command exists and is executable |
| 20 | */ |
| 21 | async function isCommandAvailable(command: string): Promise<boolean> { |
| 22 | try { |
| 23 | return !!(await which(command)) |
| 24 | } catch { |
| 25 | return false |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Check if git is available on the system. |