Skip to content

Commit 72e8e0d

Browse files
Merge #94
94: Check with which r=matthiasbeyer a=matthiasbeyer Closes #92 `@Xmoe` could you please have a look whether this is something you'd like to see here (of course also others are welcome to comment)?! Co-authored-by: Matthias Beyer <mail@beyermatthias.de>
2 parents 32d31c9 + bdee2dc commit 72e8e0d

File tree

4 files changed

+15
-0
lines changed

4 files changed

+15
-0
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
uses: actions-rs/cargo@v1
3333
with:
3434
command: check
35+
args: --all-features
3536

3637

3738
test:

Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,11 @@ regex = "1"
1919
tempfile = "3"
2020
thiserror = "1.0.34"
2121

22+
which = { version = "4.4", optional = true }
23+
2224
[badges]
2325
maintenance = { status = "passively-maintained" }
26+
27+
[features]
28+
default = []
29+
which = ["dep:which"]

src/error.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,8 @@ pub enum Error {
3939

4040
#[error("The provided program arguments cannot be parsed")]
4141
BadProgramArguments,
42+
43+
#[cfg(feature = "which")]
44+
#[error(transparent)]
45+
Which(#[from] which::Error),
4246
}

src/session.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,10 @@ pub fn spawn(program: &str, timeout_ms: Option<u64>) -> Result<PtySession, Error
232232

233233
/// See `spawn`
234234
pub fn spawn_command(command: Command, timeout_ms: Option<u64>) -> Result<PtySession, Error> {
235+
#[cfg(feature = "which")]
236+
{
237+
let _ = which::which(command.get_program())?;
238+
}
235239
let mut process = PtyProcess::new(command)?;
236240
process.set_kill_timeout(timeout_ms);
237241

0 commit comments

Comments
 (0)