Only use cygpath on windows if present (#586)

This commit is contained in:
Casey Rodarmor 2020-01-28 18:02:58 -08:00 committed by GitHub
parent 1d084f1d4e
commit 1629235f2e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View File

@ -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")),
}
}
}

View File

@ -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,
}