1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use std::path::PathBuf;
use crate::{dotsy_err, error::DotsyError, home, xdg_config_home, DotsyResult};
pub fn fallback_path() -> DotsyResult<PathBuf> {
let default_config_paths: Vec<Option<PathBuf>> = vec![
Some(PathBuf::from("./.dotsyrc.json")),
xdg_config_home!("dotsy/dotsyrc.json"),
xdg_config_home!("dotsy/dotsyrc"),
xdg_config_home!("dotsyrc.json"),
home!(".dotsyrc.json"),
];
for config_path in default_config_paths {
if let Some(path) = config_path {
if path.exists() {
return Ok(path);
}
}
}
dotsy_err!(DotsyError::NoConfigFile)
}