Skip to content

Commit cf6f40a

Browse files
authored
Merge pull request #14 from cfsamson/issue13
Corrected bug which always triggered fallback search algorithm.
2 parents 827ffea + f9ca8c3 commit cf6f40a

3 files changed

Lines changed: 9 additions & 4 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "powershell_script"
3-
version = "1.0.4"
3+
version = "1.1.0"
44
authors = ["Carl Fredrik Samson <cf@samson.no>"]
55
edition = "2018"
66
repository = "https://github.com/cfsamson/powershell-script"
@@ -16,6 +16,7 @@ A library for running Windows PowerShell scripts
1616
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
1717

1818
[features]
19+
1920
# Use PowerShell Core instead of Windows Powershell.
2021
core = []
2122

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,11 @@ mod target;
8686

8787
#[cfg(all(not(feature = "core"), windows))]
8888
/// Windows PowerShell
89-
const POWERSHELL_NAME: &str = "PowerShell";
89+
const POWERSHELL_NAME: &str = "PowerShell.exe";
9090

9191
#[cfg(any(feature = "core", not(windows)))]
9292
/// PowerShell Core
93-
const POWERSHELL_NAME: &str = "pwsh";
93+
const POWERSHELL_NAME: &str = "pwsh.exe";
9494

9595
type Result<T> = std::result::Result<T, PsError>;
9696

src/target/windows.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ impl PsScript {
2929
}
3030

3131
fn run_raw(&self, script: &str) -> Result<process::Output> {
32-
let mut cmd = Command::new(get_powershell_path()?);
32+
let pws_path = get_powershell_path()?;
33+
let mut cmd = Command::new(pws_path);
3334

3435
cmd.stdin(Stdio::piped());
3536
cmd.stdout(Stdio::piped());
@@ -62,12 +63,15 @@ fn is_program_on_path(program_name: &str) -> Option<bool> {
6263
Ok(x) => x,
6364
Err(_e) => return None,
6465
};
66+
6567
for path_dir in system_path.split(PATH_SPLITTER) {
6668
let path = std::path::Path::new(path_dir).join(&program_name);
69+
6770
if path.exists() {
6871
return Some(true);
6972
}
7073
}
74+
7175
return Some(false);
7276
}
7377

0 commit comments

Comments
 (0)