(context?: ExecutionContext)
| 16 | let cachedDockerPath: string | null = null; |
| 17 | |
| 18 | export async function resolveDockerPath(context?: ExecutionContext): Promise<string> { |
| 19 | if (cachedDockerPath) return cachedDockerPath; |
| 20 | |
| 21 | const commonPaths = [ |
| 22 | '/usr/local/bin/docker', |
| 23 | '/opt/homebrew/bin/docker', |
| 24 | '/usr/bin/docker', |
| 25 | '/bin/docker', |
| 26 | ]; |
| 27 | |
| 28 | for (const path of commonPaths) { |
| 29 | try { |
| 30 | await access(path, constants.X_OK); |
| 31 | context?.logger.debug(`[Docker] Resolved docker path to: ${path}`); |
| 32 | cachedDockerPath = path; |
| 33 | return path; |
| 34 | } catch { |
| 35 | // Continue to next path |
| 36 | } |
| 37 | } |
| 38 | |
| 39 | // Fallback to searching in PATH |
| 40 | context?.logger.info(`[Docker] Checked common paths but could not find docker. Fallback to using "docker" from PATH.`); |
| 41 | cachedDockerPath = 'docker'; |
| 42 | return 'docker'; |
| 43 | } |
| 44 | |
| 45 | |
| 46 |
no test coverage detected