Skip to main content

lean_ctx/core/
portable_binary.rs

1pub fn resolve_portable_binary() -> String {
2    let which_cmd = if cfg!(windows) { "where" } else { "which" };
3    if let Ok(status) = std::process::Command::new(which_cmd)
4        .arg("lean-ctx")
5        .stdout(std::process::Stdio::null())
6        .stderr(std::process::Stdio::null())
7        .status()
8    {
9        if status.success() {
10            return "lean-ctx".to_string();
11        }
12    }
13    std::env::current_exe()
14        .map(|p| p.to_string_lossy().to_string())
15        .unwrap_or_else(|_| "lean-ctx".to_string())
16}