(cmd: string)
| 63 | * binary exists on PATH, null otherwise. Lightweight enough to call at boot. |
| 64 | */ |
| 65 | export function resolveCommand(cmd: string): string | null { |
| 66 | if (cmd.includes('/')) return existsSync(cmd) ? cmd : null; |
| 67 | try { |
| 68 | const out = execFileSync('/bin/sh', ['-c', `command -v ${cmd}`], { |
| 69 | encoding: 'utf8', |
| 70 | timeout: 2_000, |
| 71 | }); |
| 72 | const path = out.trim(); |
| 73 | return path || null; |
| 74 | } catch { |
| 75 | return null; |
| 76 | } |
| 77 | } |
no test coverage detected