From d1432e0316a1e1b335022372ef0896c5b5b7b0df Mon Sep 17 00:00:00 2001 From: Jeff Dickey <216188+jdx@users.noreply.github.com> Date: Sun, 12 May 2024 11:01:37 -0500 Subject: [PATCH] refactor(cargo): improve cargo-binstall check --- src/forge/cargo.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/forge/cargo.rs b/src/forge/cargo.rs index 3e0fcddf1..f33102d87 100644 --- a/src/forge/cargo.rs +++ b/src/forge/cargo.rs @@ -63,11 +63,10 @@ impl Forge for CargoForge { let config = Config::try_get()?; let settings = Settings::get(); settings.ensure_experimental("cargo backend")?; - let cmd = match settings.cargo_binstall { - true if file::which_non_pristine("cargo-binstall").is_some() => { - CmdLineRunner::new("cargo-binstall").arg("-y") - } - _ => CmdLineRunner::new("cargo").arg("install"), + let cmd = if self.is_binstall_enabled() { + CmdLineRunner::new("cargo-binstall").arg("-y") + } else { + CmdLineRunner::new("cargo").arg("install") }; cmd.arg(&format!("{}@{}", self.name(), ctx.tv.version)) @@ -92,6 +91,11 @@ impl CargoForge { fa, } } + + fn is_binstall_enabled(&self) -> bool { + let settings = Settings::get(); + settings.cargo_binstall && file::which_non_pristine("cargo-binstall").is_some() + } } fn get_crate_url(n: &str) -> eyre::Result {