(command, versionArgs = ["--version"], options = {})
| 36 | } |
| 37 | |
| 38 | export function binaryAvailable(command, versionArgs = ["--version"], options = {}) { |
| 39 | const result = runCommand(command, versionArgs, options); |
| 40 | if (result.error && /** @type {NodeJS.ErrnoException} */ (result.error).code === "ENOENT") { |
| 41 | return { available: false, detail: "not found" }; |
| 42 | } |
| 43 | if (result.error) { |
| 44 | return { available: false, detail: result.error.message }; |
| 45 | } |
| 46 | if (result.status !== 0) { |
| 47 | const detail = result.stderr.trim() || result.stdout.trim() || `exit ${result.status}`; |
| 48 | return { available: false, detail }; |
| 49 | } |
| 50 | return { available: true, detail: result.stdout.trim() || result.stderr.trim() || "ok" }; |
| 51 | } |
| 52 | |
| 53 | function looksLikeMissingProcessMessage(text) { |
| 54 | return /not found|no running instance|cannot find|does not exist|no such process/i.test(text); |
no test coverage detected