fix: add 'fdfind' binary name

This commit is contained in:
Kristofers Solo 2025-04-09 13:25:58 +03:00
parent bce3c6bdba
commit 7256de34ac

View File

@ -2,6 +2,8 @@ use crate::errors::{ProjectFinderError, Result};
use tracing::info; use tracing::info;
use which::which; use which::which;
const FD_PATH: [&str; 2] = ["fd", "fdfind"];
/// Represents external dependencies required by the application. /// Represents external dependencies required by the application.
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct Dependencies { pub struct Dependencies {
@ -27,16 +29,23 @@ impl Dependencies {
pub fn check() -> Result<Self> { pub fn check() -> Result<Self> {
info!("Checking dependencies..."); info!("Checking dependencies...");
let fd_path = which("fd") let fd_path = FD_PATH
.map(|path| path.to_string_lossy().into_owned()) .iter()
.map_err(|_| { .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( 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)) Ok(Self::new(fd_path))
} }
} }