Skip to content

Commit

Permalink
fix: Default config location of pueue_aliases.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
Nukesor committed Nov 28, 2023
1 parent 4a77981 commit 07cfa14
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Fixed

- Fixed panic when calling parallel without arguments [#477](https://github.com/Nukesor/pueue/issues/477)
- Fix typo
- Fixed wrong default location for `pueue_aliases.yml` [#480](https://github.com/Nukesor/pueue/issues/480)
- Fix typos

## [3.3.1] - 2023-10-27

Expand Down
10 changes: 7 additions & 3 deletions pueue_lib/src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,15 @@ pub struct NestedSettings {
pub shared: Shared,
}

pub fn default_configuration_directory() -> Option<PathBuf> {
dirs::config_dir().map(|dir| dir.join("pueue"))
}

/// Get the default config directory.
/// If no config can be found, fallback to the current directory.
pub fn configuration_directories() -> Vec<PathBuf> {
if let Some(config_dir) = dirs::config_dir() {
vec![config_dir.join("pueue"), PathBuf::from(".")]
if let Some(config_dir) = default_configuration_directory() {
vec![config_dir, PathBuf::from(".")]
} else {
vec![PathBuf::from(".")]
}
Expand Down Expand Up @@ -269,7 +273,7 @@ impl Shared {
pub fn alias_file(&self) -> PathBuf {
if let Some(path) = &self.alias_file {
expand_home(path)
} else if let Some(config_dir) = dirs::config_dir() {
} else if let Some(config_dir) = default_configuration_directory() {
config_dir.join("pueue_aliases.yml")
} else {
PathBuf::from("pueue_aliases.yml")
Expand Down

0 comments on commit 07cfa14

Please sign in to comment.