Auto-detect Mago by checking ` /mago` then `$PATH`.
(workspace_root: Option<&Path>, bin_dir: Option<&str>)
| 98 | |
| 99 | /// Auto-detect Mago by checking `<bin_dir>/mago` then `$PATH`. |
| 100 | fn auto_detect(workspace_root: Option<&Path>, bin_dir: Option<&str>) -> Option<ResolvedMago> { |
| 101 | // Check the Composer bin directory first (vendor/bin/mago). |
| 102 | if let Some(root) = workspace_root { |
| 103 | let bin = bin_dir.unwrap_or("vendor/bin"); |
| 104 | let candidate = root.join(bin).join("mago"); |
| 105 | if candidate.is_file() { |
| 106 | return Some(ResolvedMago { path: candidate }); |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | // Fall back to $PATH. |
| 111 | if let Ok(path) = which("mago") { |
| 112 | return Some(ResolvedMago { path }); |
| 113 | } |
| 114 | |
| 115 | None |
| 116 | } |
| 117 | |
| 118 | /// Simple `which`-like lookup: search `$PATH` for an executable with |
| 119 | /// the given name. |