Use ps1 extension for pwsh shebangs (#1027)
This commit is contained in:
parent
3ef420ccb3
commit
53d3c7569c
@ -41,7 +41,7 @@ impl<'line> Shebang<'line> {
|
|||||||
pub(crate) fn script_filename(&self, recipe: &str) -> String {
|
pub(crate) fn script_filename(&self, recipe: &str) -> String {
|
||||||
match self.interpreter_filename() {
|
match self.interpreter_filename() {
|
||||||
"cmd" | "cmd.exe" => format!("{}.bat", recipe),
|
"cmd" | "cmd.exe" => format!("{}.bat", recipe),
|
||||||
"powershell" | "powershell.exe" => format!("{}.ps1", recipe),
|
"powershell" | "powershell.exe" | "pwsh" | "pwsh.exe" => format!("{}.ps1", recipe),
|
||||||
_ => recipe.to_owned(),
|
_ => recipe.to_owned(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -143,6 +143,14 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pwsh_script_filename() {
|
||||||
|
assert_eq!(
|
||||||
|
Shebang::new("#!pwsh").unwrap().script_filename("foo"),
|
||||||
|
"foo.ps1"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn powershell_exe_script_filename() {
|
fn powershell_exe_script_filename() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
@ -153,6 +161,14 @@ mod tests {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn pwsh_exe_script_filename() {
|
||||||
|
assert_eq!(
|
||||||
|
Shebang::new("#!pwsh.exe").unwrap().script_filename("foo"),
|
||||||
|
"foo.ps1"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn cmd_script_filename() {
|
fn cmd_script_filename() {
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
Loading…
Reference in New Issue
Block a user