mirror of
https://github.com/djibux/BoilR.git
synced 2026-09-01 05:53:41 +02:00
Fix config directory to read config.toml from $XDG_CONFIG_HOME/boilr, rather than $XDG_CONFIG_HOME (#338)
This commit is contained in:
+5
-6
@@ -8,7 +8,7 @@ pub fn get_config_folder() -> PathBuf {
|
|||||||
let config_home = std::env::var("XDG_CONFIG_HOME");
|
let config_home = std::env::var("XDG_CONFIG_HOME");
|
||||||
let home = std::env::var("HOME");
|
let home = std::env::var("HOME");
|
||||||
match (config_home, 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"),
|
(Err(_), Ok(home)) => Path::new(&home).join(".config").join("boilr"),
|
||||||
_ => Path::new("").to_path_buf(),
|
_ => Path::new("").to_path_buf(),
|
||||||
}
|
}
|
||||||
@@ -64,14 +64,13 @@ mod tests {
|
|||||||
// Parameters for set environment 'XDG_CONFIG_HOME'
|
// Parameters for set environment 'XDG_CONFIG_HOME'
|
||||||
std::env::set_var(
|
std::env::set_var(
|
||||||
"XDG_CONFIG_HOME",
|
"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 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]
|
#[test]
|
||||||
@@ -79,7 +78,7 @@ mod tests {
|
|||||||
fn check_return_config_path() {
|
fn check_return_config_path() {
|
||||||
std::env::set_var(
|
std::env::set_var(
|
||||||
"XDG_CONFIG_HOME",
|
"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();
|
let config_path = get_config_folder();
|
||||||
|
|||||||
Reference in New Issue
Block a user