Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to env_home crate #105

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading