Skip to content

Commit

Permalink
Switch to env_home crate. Fixes #104
Browse files Browse the repository at this point in the history
  • Loading branch information
micolous authored and Xaeroxe committed Dec 19, 2024
1 parent 1b5f7be commit 36cb494
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ regex = { version = "1.10.2", optional = true }
tracing = { version = "0.1.40", default-features = false, optional = true }

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

[target.'cfg(any(unix, target_os = "wasi", target_os = "redox"))'.dependencies]
rustix = { version = "0.38.30", default-features = false, features = ["fs", "std"] }
Expand Down
8 changes: 4 additions & 4 deletions src/finder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ use std::fs;
use std::iter;
use std::path::{Component, Path, PathBuf};

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

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

Expand Down Expand Up @@ -266,7 +266,7 @@ fn tilde_expansion(p: &PathBuf) -> Cow<'_, PathBuf> {
let mut component_iter = p.components();
if let Some(Component::Normal(o)) = component_iter.next() {
if o == "~" {
let mut new_path = home_dir().unwrap_or_default();
let mut new_path = env_home_dir().unwrap_or_default();
new_path.extend(component_iter);
#[cfg(feature = "tracing")]
tracing::trace!(
Expand Down

0 comments on commit 36cb494

Please sign in to comment.