mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-06-16 07:36:38 +00:00
Address feedback, make e2e-test test both source/non-source.
This commit is contained in:
parent
a27560fce9
commit
90578aa10d
4 changed files with 44 additions and 13 deletions
|
@ -1,5 +1,6 @@
|
|||
use std::{borrow::Cow, env, ffi::OsStr, fmt, iter, path::Path, sync::Arc};
|
||||
|
||||
use binstalk_bins::BinFile;
|
||||
use command_group::AsyncCommandGroup;
|
||||
use compact_str::{CompactString, ToCompactString};
|
||||
use either::Either;
|
||||
|
@ -87,19 +88,27 @@ impl ResolutionFetch {
|
|||
current_version: self.new_version,
|
||||
source: self.source,
|
||||
target: self.fetcher.target().to_compact_string(),
|
||||
bins: opts
|
||||
.bins
|
||||
.as_ref()
|
||||
.map(|bins| bins.iter().cloned().map(Into::into).collect())
|
||||
.unwrap_or_else(|| {
|
||||
self.bin_files
|
||||
.into_iter()
|
||||
.map(|bin| bin.base_name)
|
||||
.collect()
|
||||
}),
|
||||
bins: Self::resolve_bins(&opts.bins, &self.bin_files),
|
||||
})
|
||||
}
|
||||
|
||||
fn resolve_bins(
|
||||
user_specified_bins: &Option<Vec<CompactString>>,
|
||||
crate_bin_files: &[BinFile],
|
||||
) -> Vec<CompactString> {
|
||||
// We need to filter crate_bin_files by user_specified_bins in case the prebuilt doesn't
|
||||
// have featured-gated (optional) binary (gated behind feature).
|
||||
crate_bin_files
|
||||
.iter()
|
||||
.map(|bin| bin.base_name.clone())
|
||||
.filter(|bin_name| {
|
||||
user_specified_bins
|
||||
.as_ref()
|
||||
.map_or(true, |bins| bins.binary_search(bin_name).is_ok())
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn print(&self, opts: &Options) {
|
||||
let fetcher = &self.fetcher;
|
||||
let bin_files = &self.bin_files;
|
||||
|
@ -190,6 +199,10 @@ impl ResolutionSource {
|
|||
cmd.arg("--no-track");
|
||||
}
|
||||
|
||||
if let Some(bins) = &opts.bins {
|
||||
cmd.args(bins.iter().flat_map(|bin| ["--bin", bin.as_ref()]));
|
||||
}
|
||||
|
||||
debug!("Running `{}`", format_cmd(&cmd));
|
||||
|
||||
if !opts.dry_run {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue