(
resolved: &ResolvedRuntime,
store: &Store,
command: &str,
install_on_demand_eligible: bool,
install_on_demand_scope: impl Into<String>,
)
| 39 | |
| 40 | impl RuntimeCommandAvailability { |
| 41 | pub fn for_resolved_runtime( |
| 42 | resolved: &ResolvedRuntime, |
| 43 | store: &Store, |
| 44 | command: &str, |
| 45 | install_on_demand_eligible: bool, |
| 46 | install_on_demand_scope: impl Into<String>, |
| 47 | ) -> Self { |
| 48 | let runtime_root = runtime_root_for_resolved_runtime(resolved, store); |
| 49 | let checked_path_values = runtime_root |
| 50 | .as_deref() |
| 51 | .map(|root| runtime_executable_candidate_paths(root, command)) |
| 52 | .unwrap_or_else(|| vec![PathBuf::from("<runtime-not-installed>").join(command)]); |
| 53 | let selected_path = selected_existing_or_primary(&checked_path_values); |
| 54 | let direct_executable_exists = selected_path.exists(); |
| 55 | let direct_executable_runnable = runtime_executable_is_runnable(&selected_path); |
| 56 | let npm_exec_fallback = npm_exec_fallback_for_command( |
| 57 | runtime_root.as_deref(), |
| 58 | command, |
| 59 | direct_executable_exists, |
| 60 | ); |
| 61 | let (linked_runtime_name, linked_runtime_path) = linked_runtime_details(resolved); |
| 62 | |
| 63 | Self { |
| 64 | command: command.to_string(), |
| 65 | runtime: resolved.runtime_id(), |
| 66 | linked_runtime_name, |
| 67 | linked_runtime_path, |
| 68 | checked_paths: checked_path_values |
| 69 | .iter() |
| 70 | .map(|path| path.display().to_string()) |
| 71 | .collect(), |
| 72 | selected_path: selected_path.display().to_string(), |
| 73 | direct_executable_exists, |
| 74 | direct_executable_runnable, |
| 75 | managed_shim_available: direct_executable_runnable || npm_exec_fallback.is_some(), |
| 76 | availability_mode: availability_mode(direct_executable_runnable, &npm_exec_fallback) |
| 77 | .to_string(), |
| 78 | delegated_executable_path: npm_exec_fallback |
| 79 | .as_ref() |
| 80 | .map(|path| path.display().to_string()), |
| 81 | install_on_demand_eligible, |
| 82 | install_on_demand_scope: install_on_demand_scope.into(), |
| 83 | path_precedence_guidance: PATH_PRECEDENCE_GUIDANCE, |
| 84 | } |
| 85 | } |
| 86 | |
| 87 | pub fn for_linked_runtime( |
| 88 | name: &str, |
nothing calls this directly
no test coverage detected