-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Find .cmd or .bat in paths.
- Loading branch information
Showing
2 changed files
with
122 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
#![cfg(windows)] | ||
|
||
use xshell::{cmd, Shell}; | ||
|
||
#[test] | ||
fn npm() { | ||
let sh = Shell::new().unwrap(); | ||
|
||
if cmd!(sh, "where npm").read().is_ok() { | ||
let script_shell = cmd!(sh, "npm get shell").read().unwrap(); | ||
assert!(script_shell.ends_with(".exe")); | ||
|
||
let script_shell_explicit = cmd!(sh, "npm.cmd get shell").read().unwrap(); | ||
assert_eq!(script_shell, script_shell_explicit); | ||
} | ||
} | ||
|
||
#[test] | ||
fn overridden_cmd_path() { | ||
let sh = Shell::new().unwrap(); | ||
|
||
if cmd!(sh, "where npm").read().is_ok() { | ||
// should fail as `PATH` is overridden via Cmd | ||
assert!(cmd!(sh, "npm get shell").env("PATH", ".").run().is_err()); | ||
} | ||
} | ||
|
||
#[test] | ||
fn overridden_shell_path() { | ||
let mut sh = Shell::new().unwrap(); | ||
sh.set_var("PATH", "."); | ||
|
||
if cmd!(sh, "where npm").read().is_ok() { | ||
// should fail as `PATH` is overridden via Shell | ||
assert!(cmd!(sh, "npm get shell").env("PATH", ".").run().is_err()); | ||
} | ||
} |