Replace dirs with dirs-next dependency (#1361)

`dirs` will be unmaintained for the foreseeable future, so
switch to the maintained fork `dirs-next`.

Closes #1319.
This commit is contained in:
Julian Gehring
2020-06-20 18:59:35 +01:00
committed by GitHub
parent ee3c0ec9d5
commit d21cb62e3a
11 changed files with 36 additions and 41 deletions
+2 -2
View File
@@ -168,7 +168,7 @@ fn get_terminal_info() -> TerminalInfo {
}
fn get_config_path(shell: &str) -> Option<PathBuf> {
dirs::home_dir().and_then(|home_dir| {
dirs_next::home_dir().and_then(|home_dir| {
match shell {
"bash" => Some(".bashrc"),
"fish" => Some(".config/fish/config.fish"),
@@ -192,7 +192,7 @@ fn get_starship_config() -> String {
.map(PathBuf::from)
.ok()
.or_else(|| {
dirs::home_dir().map(|mut home_dir| {
dirs_next::home_dir().map(|mut home_dir| {
home_dir.push(".config/starship.toml");
home_dir
})
+1 -2
View File
@@ -6,7 +6,6 @@ use std::clone::Clone;
use std::collections::HashMap;
use std::marker::Sized;
use dirs::home_dir;
use std::env;
use toml::Value;
@@ -205,7 +204,7 @@ impl StarshipConfig {
} else {
// Default to using ~/.config/starship.toml
log::debug!("STARSHIP_CONFIG is not set");
let config_path = home_dir()?.join(".config/starship.toml");
let config_path = dirs_next::home_dir()?.join(".config/starship.toml");
let config_path_str = config_path.to_str()?.to_owned();
log::debug!("Using default config path: {}", config_path_str);
config_path_str
+1 -1
View File
@@ -109,7 +109,7 @@ fn get_editor_internal(visual: Option<OsString>, editor: Option<OsString>) -> Os
fn get_config_path() -> OsString {
let config_path = env::var_os("STARSHIP_CONFIG").unwrap_or_else(|| "".into());
if config_path.is_empty() {
dirs::home_dir()
dirs_next::home_dir()
.expect("couldn't find home directory")
.join(".config/starship.toml")
.as_os_str()
+1 -1
View File
@@ -89,7 +89,7 @@ impl<'a> Context<'a> {
fn expand_tilde(dir: PathBuf) -> PathBuf {
if dir.starts_with("~") {
let without_home = dir.strip_prefix("~").unwrap();
return dirs::home_dir().unwrap().join(without_home);
return dirs_next::home_dir().unwrap().join(without_home);
}
dir
}
+1 -3
View File
@@ -5,8 +5,6 @@ use std::io::{BufRead, BufReader};
use std::path::PathBuf;
use std::str::FromStr;
use dirs::home_dir;
use super::{Context, Module, RootModuleConfig};
use crate::configs::aws::{AwsConfig, AwsItems};
@@ -19,7 +17,7 @@ fn get_aws_region_from_config(aws_profile: Option<&str>) -> Option<Region> {
.ok()
.and_then(|path| PathBuf::from_str(&path).ok())
.or_else(|| {
let mut home = home_dir()?;
let mut home = dirs_next::home_dir()?;
home.push(".aws/config");
Some(home)
})?;
+1 -1
View File
@@ -56,7 +56,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
.unwrap_or_else(|| &context.current_dir),
);
let home_dir = dirs::home_dir().unwrap();
let home_dir = dirs_next::home_dir().unwrap();
log::debug!("Current directory: {:?}", current_dir);
let repo = &context.get_repo().ok()?;
+1 -3
View File
@@ -1,5 +1,3 @@
use dirs::home_dir;
use super::{Context, Module, RootModuleConfig};
use crate::configs::docker_context::DockerContextConfig;
@@ -26,7 +24,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
return None;
}
let config_path = home_dir()?.join(DOCKER_CONFIG_FILE);
let config_path = dirs_next::home_dir()?.join(DOCKER_CONFIG_FILE);
let json = utils::read_file(config_path).ok()?;
let parsed_json = serde_json::from_str(&json).ok()?;
+1 -1
View File
@@ -48,7 +48,7 @@ pub fn module<'a>(context: &'a Context) -> Option<Module<'a>> {
.filter_map(|filename| parse_kubectl_file(&filename))
.next(),
Err(_) => {
let filename = dirs::home_dir()?.join(".kube").join("config");
let filename = dirs_next::home_dir()?.join(".kube").join("config");
parse_kubectl_file(&filename)
}
};