mirror of
https://github.com/casey/just.git
synced 2025-08-04 15:08:39 +00:00
Merge ed34026f0f
into 33936f4918
This commit is contained in:
commit
fb608b451b
1 changed files with 38 additions and 0 deletions
|
@ -21,6 +21,14 @@ impl Search {
|
|||
if let Some(home_dir) = dirs::home_dir() {
|
||||
paths.push((home_dir.join(".config").join("just"), DEFAULT_JUSTFILE_NAME));
|
||||
|
||||
if let Some(xdg_config_home) = std::env::var_os("XDG_CONFIG_HOME") {
|
||||
paths.push(
|
||||
PathBuf::from(xdg_config_home)
|
||||
.join("just")
|
||||
.join(DEFAULT_JUSTFILE_NAME)
|
||||
);
|
||||
};
|
||||
|
||||
for justfile_name in JUSTFILE_NAMES {
|
||||
paths.push((home_dir.clone(), justfile_name));
|
||||
}
|
||||
|
@ -399,4 +407,34 @@ mod tests {
|
|||
assert_eq!(have, Path::new(want));
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn global_justfile_path_from_xdg_env(){
|
||||
let old_value = std::env::var_os("XDG_CONFIG_HOME");
|
||||
|
||||
std::env::set_var("XDG_CONFIG_HOME", "/test/config");
|
||||
|
||||
let paths = Search::global_justfile_paths();
|
||||
assert!(paths.contains(&PathBuf::from("/test/config/just/justfile")));
|
||||
|
||||
if let Some(old) = old_value {
|
||||
std::env::set_var("XDG_CONFIG_HOME", old);
|
||||
} else {
|
||||
std::env::remove_var("XDG_CONFIG_HOME");
|
||||
}
|
||||
}
|
||||
#[test]
|
||||
fn global_justfile_path_when_xdg_env_not_set(){
|
||||
let old_value = std::env::var_os("XDG_CONFIG_HOME");
|
||||
|
||||
std::env::set_var("XDG_CONFIG_HOME", "");
|
||||
|
||||
let paths = Search::global_justfile_paths();
|
||||
assert!(!paths.contains(&PathBuf::from("/test/config/just/justfile")));
|
||||
|
||||
if let Some(old) = old_value {
|
||||
std::env::set_var("XDG_CONFIG_HOME", old);
|
||||
} else {
|
||||
std::env::remove_var("XDG_CONFIG_HOME");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue