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 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))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user