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

@@ -1344,7 +1344,7 @@ fn main() -> Result<()> {
if let Ok(config) = &parsed_config {
if let Some(asc_path) = config.get("app_specific_configuration_path") {
let normalized_asc_path = asc_path
let mut normalized_asc_path = asc_path
.to_string()
.replace(
"$Env:USERPROFILE",
@@ -1353,6 +1353,13 @@ fn main() -> Result<()> {
.replace('"', "")
.replace('\\', "/");
if let Ok(komorebi_config_home) = std::env::var("KOMOREBI_CONFIG_HOME") {
normalized_asc_path = normalized_asc_path
.replace("$Env:KOMOREBI_CONFIG_HOME", &komorebi_config_home)
.replace('"', "")
.replace('\\', "/");
}
if !Path::exists(Path::new(&normalized_asc_path)) {
println!("Application specific configuration file path '{normalized_asc_path}' does not exist. Try running 'komorebic fetch-asc'\n");
}