From f181379914b1ef7f373aea1e8034e46b076549d7 Mon Sep 17 00:00:00 2001 From: Daedalusspacegames Date: Mon, 27 Mar 2023 11:57:17 -0700 Subject: [PATCH] Fix config directory to read config.toml from `$XDG_CONFIG_HOME/boilr`, rather than `$XDG_CONFIG_HOME` (#338) --- src/config.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/config.rs b/src/config.rs index a1665f3..68196ae 100644 --- a/src/config.rs +++ b/src/config.rs @@ -8,7 +8,7 @@ pub fn get_config_folder() -> PathBuf { let config_home = std::env::var("XDG_CONFIG_HOME"); let home = std::env::var("HOME"); match (config_home, home) { - (Ok(p), _) => Path::new(&p).to_path_buf(), + (Ok(p), _) => Path::new(&p).join("boilr"), (Err(_), Ok(home)) => Path::new(&home).join(".config").join("boilr"), _ => Path::new("").to_path_buf(), } @@ -64,14 +64,13 @@ mod tests { // Parameters for set environment 'XDG_CONFIG_HOME' std::env::set_var( "XDG_CONFIG_HOME", - std::env::var("HOME").unwrap_or_default() + "/.config/boilr", + std::env::var("HOME").unwrap_or_default() + "/.config", ); - let xdg_config_home = std::env::var("XDG_CONFIG_HOME").unwrap_or_default(); + let xdg_config_home = std::env::var("XDG_CONFIG_HOME").unwrap_or_default() + "/boilr"; let config_path = get_config_folder(); - let test_path = PathBuf::from(xdg_config_home); - assert_eq!(config_path, test_path); + assert_eq!(config_path, PathBuf::from(xdg_config_home)); } #[test] @@ -79,7 +78,7 @@ mod tests { fn check_return_config_path() { std::env::set_var( "XDG_CONFIG_HOME", - std::env::var("HOME").unwrap_or_default() + "/.config/boilr", + std::env::var("HOME").unwrap_or_default() + "/.config", ); let config_path = get_config_folder();