Skip to content

Commit

Permalink
Switch from dirs crate to cargo-team maintained home crate
Browse files Browse the repository at this point in the history
  • Loading branch information
oherrala committed Sep 4, 2023
1 parent 74b713d commit 76f6a0f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ categories = ["os", "filesystem"]
keywords = ["which", "which-rs", "unix", "command"]

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

Expand Down
13 changes: 12 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 Down Expand Up @@ -249,3 +248,15 @@ fn correct_casing(mut p: PathBuf) -> PathBuf {
fn correct_casing(p: PathBuf) -> PathBuf {
p
}

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

// This is for wasm platform (and maybe others) where home directory is not
// defined. See: https://github.com/rust-lang/cargo/issues/12297
#[cfg(not(any(unix, target_os = "redox", windows)))]
fn home_dir() -> Option<PathBuf> {
None
}

0 comments on commit 76f6a0f

Please sign in to comment.