Detect reports whether the tool's CLI binary is on PATH and, when installed, its version string in a single pass. Version detection is skipped for missing binaries — we never spawn a doomed process just to learn the binary is absent — and each probe is bounded by versionProbeTimeout so one hung bina
(tool Tool)
| 163 | // stall the caller. Prefer this over IsInstalled + DetectVersion when you need |
| 164 | // both values. |
| 165 | func Detect(tool Tool) (installed bool, version string) { |
| 166 | bin := tool.LaunchCommand() |
| 167 | if bin == "" { |
| 168 | return false, "" |
| 169 | } |
| 170 | if _, err := exec.LookPath(bin); err != nil { |
| 171 | return false, "" |
| 172 | } |
| 173 | return true, detectVersion(bin) |
| 174 | } |
| 175 | |
| 176 | // DetectVersion returns the tool's version string by running `<bin> --version`. |
| 177 | // Returns "unknown" when the binary is missing or every probe fails (including |
no test coverage detected