Skip to content

Commit

Permalink
fix: make is_executable more portable
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed Dec 1, 2023
1 parent 4f34485 commit c228686
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ jobs:

- name: Run tests
env:
RUST_BACKTRACE: "1"
RUST_BACKTRACE: "full"
run: just test

- uses: taiki-e/install-action@v2
Expand Down
11 changes: 6 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ impl CommandRunner {
}

pub fn is_executable(&self) -> bool {
Command::new("command")
.args(["-v", &self.command])
.output()
.map(|output| output.status.success())
.unwrap_or(false)
let cmd = format!("command -v {}", &self.command);
let result = Command::new("sh").args(["-c", &cmd]).output();
match result {
Ok(output) => output.status.success(),
Err(_) => false,
}
}
}

Expand Down

0 comments on commit c228686

Please sign in to comment.