Skip to content

Commit

Permalink
refactor(cargo): improve cargo-binstall check
Browse files Browse the repository at this point in the history
  • Loading branch information
jdx committed May 12, 2024
1 parent 76202de commit d1432e0
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/forge/cargo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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<Url> {
Expand Down

0 comments on commit d1432e0

Please sign in to comment.