Skip to content

Commit

Permalink
fix: allow --paths-cmd to run on Windows (#23)
Browse files Browse the repository at this point in the history
* fix: allow path comands to run on Windows

* Call command

* Parse command

* Add empty check

* Update git.rs
  • Loading branch information
justinchuby authored Dec 5, 2022
1 parent 95f360f commit a1c4191
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ blake3 = "1.3.1"
fern = { version = "0.6.1", features = ["colored"] }
chrono = "0.4.19"
dialoguer = "0.10.1"
shell-words = "1.1.0"

[dev-dependencies]
assert_cmd = "2.0.4"
Expand Down
11 changes: 8 additions & 3 deletions src/git.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ pub fn get_head() -> Result<String> {

pub fn get_paths_from_cmd(paths_cmd: &str) -> Result<Vec<AbsPath>> {
debug!("Running paths_cmd: {}", paths_cmd);
let output = Command::new("sh")
.arg("-c")
.arg(paths_cmd)
if paths_cmd.is_empty() {
return Err(anyhow::Error::msg("paths_cmd is empty. Please provide an executable command."));
}
let argv = shell_words::split(paths_cmd).context("failed to split paths_cmd")?;
debug!("Parsed paths_cmd: {:?}", argv);

let output = Command::new(&argv[0])
.args(&argv[1..])
.output()
.context("failed to run provided paths_cmd")?;

Expand Down

0 comments on commit a1c4191

Please sign in to comment.