diff --git a/src/platform.rs b/src/platform.rs index 222baf0..05094d3 100644 --- a/src/platform.rs +++ b/src/platform.rs @@ -88,6 +88,13 @@ impl PlatformInterface for Platform { cygpath.current_dir(working_directory); cygpath.arg("--unix"); cygpath.arg(path); - output(cygpath).map_err(|e| format!("Error converting shell path: {}", e)) + + match output(cygpath) { + Ok(shell_path) => Ok(shell_path), + Err(_) => path + .to_str() + .map(str::to_string) + .ok_or_else(|| String::from("Error getting current directory: unicode decode error")), + } } } diff --git a/tests/integration.rs b/tests/integration.rs index d633500..1ce794a 100644 --- a/tests/integration.rs +++ b/tests/integration.rs @@ -2439,3 +2439,19 @@ test! { status: EXIT_FAILURE, shell: false, } + +#[cfg(windows)] +test! { + name: pwsh_invocation_directory, + justfile: r#" + set shell := ["pwsh", "-NoProfile", "-c"] + + pwd: + @Test-Path {{invocation_directory()}} > result.txt + "#, + args: (), + stdout: "", + stderr: "", + status: EXIT_SUCCESS, + shell: false, +}