mirror of
https://github.com/kristoferssolo/project-finder.git
synced 2025-10-21 19:50:35 +00:00
fix: add 'fdfind' binary name
This commit is contained in:
parent
bce3c6bdba
commit
7256de34ac
@ -2,6 +2,8 @@ use crate::errors::{ProjectFinderError, Result};
|
||||
use tracing::info;
|
||||
use which::which;
|
||||
|
||||
const FD_PATH: [&str; 2] = ["fd", "fdfind"];
|
||||
|
||||
/// Represents external dependencies required by the application.
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Dependencies {
|
||||
@ -27,16 +29,23 @@ impl Dependencies {
|
||||
pub fn check() -> Result<Self> {
|
||||
info!("Checking dependencies...");
|
||||
|
||||
let fd_path = which("fd")
|
||||
.map(|path| path.to_string_lossy().into_owned())
|
||||
.map_err(|_| {
|
||||
let fd_path = FD_PATH
|
||||
.iter()
|
||||
.find_map(|binary| {
|
||||
if let Ok(path) = which(binary) {
|
||||
let fd_path = path.to_string_lossy().into_owned();
|
||||
info!("Found {binary} at: {}", fd_path);
|
||||
return Some(fd_path);
|
||||
}
|
||||
None
|
||||
})
|
||||
.ok_or_else(|| {
|
||||
ProjectFinderError::DependencyNotFound(
|
||||
"fd - install from https://github.com/sharkdp/fd".into(),
|
||||
"Neither 'fd' nor 'fdfind' was found. Please install fd from https://github.com/sharkdp/fd"
|
||||
.into(),
|
||||
)
|
||||
})?;
|
||||
|
||||
info!("Found fd at: {fd_path}");
|
||||
|
||||
Ok(Self::new(fd_path))
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user