()
| 14 | |
| 15 | /** Cached check for whether the `rg` binary is callable. */ |
| 16 | export async function hasRipgrep(): Promise<boolean> { |
| 17 | if (ripgrepAvailable !== null) return ripgrepAvailable; |
| 18 | return new Promise((resolve) => { |
| 19 | let proc; |
| 20 | try { |
| 21 | proc = spawn('rg', ['--version'], { stdio: 'ignore' }); |
| 22 | } catch { |
| 23 | ripgrepAvailable = false; |
| 24 | resolve(false); |
| 25 | return; |
| 26 | } |
| 27 | proc.on('close', (code) => { ripgrepAvailable = code === 0; resolve(ripgrepAvailable); }); |
| 28 | proc.on('error', () => { ripgrepAvailable = false; resolve(false); }); |
| 29 | }); |
| 30 | } |
| 31 | |
| 32 | /** Test hook: force the availability cache (pass `null` to clear and re-probe). */ |
| 33 | export function __setRipgrepAvailable(v: boolean | null): void { |
no outgoing calls
no test coverage detected