Check if a given `PackageManager` executable is available on `PATH`. On Windows, npm/pnpm/yarn are `.cmd` shims while bun is a `.exe`, so we check the platform-appropriate extension.
(pm: crate::spacetime_config::PackageManager)
| 62 | /// On Windows, npm/pnpm/yarn are `.cmd` shims while bun is a `.exe`, |
| 63 | /// so we check the platform-appropriate extension. |
| 64 | pub(crate) fn has_package_manager(pm: crate::spacetime_config::PackageManager) -> bool { |
| 65 | let name = pm.to_string(); |
| 66 | if cfg!(windows) { |
| 67 | // bun ships as bun.exe; npm, pnpm, yarn are .cmd shims |
| 68 | let ext = if name == "bun" { "exe" } else { "cmd" }; |
| 69 | find_executable(format!("{name}.{ext}")).is_some() |
| 70 | } else { |
| 71 | find_executable(&name).is_some() |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | #[cfg(test)] |
| 76 | mod tests { |
no test coverage detected
searching dependent graphs…