feat(config): recognize komorebi_config_home for asc path

This commit ensures that the KOMOREBI_CONFIG_HOME environment variable is recognized by the
komorebic check command and the static config loader when used to specify the location of the
applications.yaml file.

resolve #660
This commit is contained in:
LGUG2Z
2024-02-09 16:49:49 -08:00
parent 5d812aa41d
commit b64c0e127d
2 changed files with 18 additions and 1 deletions

View File

@@ -319,6 +319,16 @@ pub fn resolve_home_path<P: AsRef<Path>>(path: P) -> Result<PathBuf> {
resolved = true;
}
std::path::Component::Normal(c) if (c == "$Env:KOMOREBI_CONFIG_HOME") && !resolved => {
let komorebi_config_home =
PathBuf::from(std::env::var("KOMOREBI_CONFIG_HOME").ok().ok_or_else(|| {
anyhow!("there is no KOMOREBI_CONFIG_HOME environment variable set")
})?);
resolved_path.extend(komorebi_config_home.components());
resolved = true;
}
_ => resolved_path.push(c),
}
}