Skip to content

Commit

Permalink
Remove dependency on dirs crate, use home instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Xaeroxe committed Sep 4, 2023
1 parent 74b713d commit 30abde4
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ categories = ["os", "filesystem"]
keywords = ["which", "which-rs", "unix", "command"]

[dependencies]
dirs = "5.0.1"
either = "1.6.1"
regex = { version = "1.5.5", optional = true }
rustix = { version = "0.38.10", default-features = false, features = ["fs", "std"] }

[target.'cfg(any(windows, unix, target_os = "redox"))'.dependencies]
home = "0.5.5"

[target.'cfg(windows)'.dependencies]
once_cell = "1"

Expand Down
10 changes: 9 additions & 1 deletion src/finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ use crate::checker::CompositeChecker;
use crate::error::*;
#[cfg(windows)]
use crate::helper::has_executable_extension;
use dirs::home_dir;
use either::Either;
#[cfg(feature = "regex")]
use regex::Regex;
Expand All @@ -16,6 +15,15 @@ use std::fs;
use std::iter;
use std::path::{Component, Path, PathBuf};

// Home dir shim, use home crate when possible. Otherwise, return None
#[cfg(any(windows, unix, target_os = "redox"))]
use home::home_dir;

#[cfg(not(any(windows, unix, target_os = "redox")))]
fn home_dir() -> Option<std::path::PathBuf> {
None
}

pub trait Checker {
fn is_valid(&self, path: &Path) -> bool;
}
Expand Down

0 comments on commit 30abde4

Please sign in to comment.