From 53d3c7569ce07da97c49061135094ac9f1b23f55 Mon Sep 17 00:00:00 2001 From: David Ringo Date: Tue, 16 Nov 2021 23:24:29 -0500 Subject: [PATCH] Use ps1 extension for pwsh shebangs (#1027) --- src/shebang.rs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/shebang.rs b/src/shebang.rs index c3a05c4..1b7852a 100644 --- a/src/shebang.rs +++ b/src/shebang.rs @@ -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!(