MCPcopy Create free account
hub / github.com/PHPantom-dev/phpantom_lsp / auto_detect

Function auto_detect

src/mago.rs:100–116  ·  view source on GitHub ↗

Auto-detect Mago by checking ` /mago` then `$PATH`.

(workspace_root: Option<&Path>, bin_dir: Option<&str>)

Source from the content-addressed store, hash-verified

98
99/// Auto-detect Mago by checking `<bin_dir>/mago` then `$PATH`.
100fn 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.

Callers 1

resolve_magoFunction · 0.70

Calls 1

whichFunction · 0.70

Tested by

no test coverage detected