Skip to content

Commit

Permalink
Use all the paths that the Walrus CLI uses
Browse files Browse the repository at this point in the history
  • Loading branch information
Tzal3x committed Oct 23, 2024
1 parent 8406e34 commit 3e5e838
Showing 1 changed file with 32 additions and 4 deletions.
36 changes: 32 additions & 4 deletions site-builder/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,11 +214,39 @@ async fn run() -> Result<()> {
let mut config: Config = std::fs::read_to_string(&args.config)
.or_else(|err| {
if err.kind() == std::io::ErrorKind::NotFound {
let config;
if let Ok(xdg_config_home) = std::env::var("XDG_CONFIG_HOME") {
return std::fs::read_to_string(
PathBuf::from(xdg_config_home)
.join("walrus")
.join("sites-config.yaml"),
);
}
Err(err)
} else {
Err(err)
}
})
.or_else(|err| {
if err.kind() == std::io::ErrorKind::NotFound {
if let Some(home_dir) = home::home_dir() {
return std::fs::read_to_string(
home_dir
.join(".config")
.join("walrus")
.join("sites-config.yaml"),
);
}
Err(err)
} else {
Err(err)
}
})
.or_else(|err| {
if err.kind() == std::io::ErrorKind::NotFound {
if let Some(home_dir) = home::home_dir() {
config =
std::fs::read_to_string(home_dir.join(".walrus").join("sites-config.yaml"));
return config;
return std::fs::read_to_string(
home_dir.join(".walrus").join("sites-config.yaml"),
);
}
Err(err)
} else {
Expand Down

0 comments on commit 3e5e838

Please sign in to comment.