Skip to content

Commit

Permalink
Only use cygpath on windows if present (#586)
Browse files Browse the repository at this point in the history
  • Loading branch information
casey authored Jan 29, 2020
1 parent 1d084f1 commit 1629235
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/platform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")),
}
}
}
16 changes: 16 additions & 0 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

0 comments on commit 1629235

Please sign in to comment.