fix(cli): smarter windows path resolution

This commit improves Windows path resolution so that when people run the
ahk-asc command with "applications.yaml" as an argument, without having
".\" prepended, the command will still succeed as expected.

fix #192
This commit is contained in:
LGUG2Z
2022-07-27 20:52:52 -07:00
parent f8cf70ee1d
commit 763c710770
+11 -8
View File
@@ -1293,15 +1293,18 @@ fn resolve_windows_path(raw_path: &str) -> Result<PathBuf> {
.parent() .parent()
.ok_or_else(|| anyhow!("cannot parse directory"))?; .ok_or_else(|| anyhow!("cannot parse directory"))?;
let file = full_path Ok(if parent.is_dir() {
.components() let file = full_path
.last() .components()
.ok_or_else(|| anyhow!("cannot parse filename"))?; .last()
.ok_or_else(|| anyhow!("cannot parse filename"))?;
let mut canonicalized = std::fs::canonicalize(parent)?; let mut canonicalized = std::fs::canonicalize(parent)?;
canonicalized.push(file); canonicalized.push(file);
canonicalized
Ok(canonicalized) } else {
full_path
})
} }
fn show_window(hwnd: HWND, command: SHOW_WINDOW_CMD) { fn show_window(hwnd: HWND, command: SHOW_WINDOW_CMD) {