Use ps1 extension for pwsh shebangs (#1027)

This commit is contained in:
David Ringo 2021-11-16 23:24:29 -05:00 committed by GitHub
parent 3ef420ccb3
commit 53d3c7569c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -41,7 +41,7 @@ impl<'line> Shebang<'line> {
pub(crate) fn script_filename(&self, recipe: &str) -> String {
match self.interpreter_filename() {
"cmd" | "cmd.exe" => format!("{}.bat", recipe),
"powershell" | "powershell.exe" => format!("{}.ps1", recipe),
"powershell" | "powershell.exe" | "pwsh" | "pwsh.exe" => format!("{}.ps1", recipe),
_ => 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]
fn powershell_exe_script_filename() {
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]
fn cmd_script_filename() {
assert_eq!(