File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11[package ]
22name = " powershell_script"
3- version = " 1.0.4 "
3+ version = " 1.1.0 "
44authors = [" Carl Fredrik Samson <cf@samson.no>" ]
55edition = " 2018"
66repository = " 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.
2021core = []
2122
Original file line number Diff line number Diff 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
9595type Result < T > = std:: result:: Result < T , PsError > ;
9696
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments