diff --git a/blaze-core/src/main/java/com/fizzed/blaze/local/LocalExec.java b/blaze-core/src/main/java/com/fizzed/blaze/local/LocalExec.java index 147e5bbd..77aa0e2a 100644 --- a/blaze-core/src/main/java/com/fizzed/blaze/local/LocalExec.java +++ b/blaze-core/src/main/java/com/fizzed/blaze/local/LocalExec.java @@ -125,7 +125,7 @@ protected Exec.Result doRun() throws BlazeException { if (exeFile.getFileName().toString().toLowerCase().endsWith(".ps1")) { // we need to actually execute powershell.exe final Path powershellExe = new Which(context) - .command("powershell.exe") + .command("powershell") .run(); finalCommand.add(powershellExe.toAbsolutePath().toString()); diff --git a/blaze-core/src/test/java/com/fizzed/blaze/system/ExecTest.java b/blaze-core/src/test/java/com/fizzed/blaze/system/ExecTest.java index ab48c77d..c84347c2 100644 --- a/blaze-core/src/test/java/com/fizzed/blaze/system/ExecTest.java +++ b/blaze-core/src/test/java/com/fizzed/blaze/system/ExecTest.java @@ -123,6 +123,22 @@ public void captureOutput() throws Exception { assertThat(output.trim(), is("Hello World 7586930100")); } + + @Test + public void captureOutputWithPs1() throws Exception { + CaptureOutput capture = Streamables.captureOutput(); + + new LocalExec(context) + .command("hello-world-test2") // will be .ps1 on windows, using powershell.exe + .path(getBinDirAsResource()) + .pipeInput(Streamables.standardInput()) + .pipeOutput(capture) + .run(); + + String output = capture.asString(); + + assertThat(output.trim(), is("Hello World 5624112309877")); + } @Test public void customInput() throws Exception { diff --git a/blaze-core/src/test/resources/bin/hello-world-test2 b/blaze-core/src/test/resources/bin/hello-world-test2 new file mode 100644 index 00000000..ded79c7a --- /dev/null +++ b/blaze-core/src/test/resources/bin/hello-world-test2 @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +echo "Hello World 5624112309877" \ No newline at end of file diff --git a/blaze-core/src/test/resources/bin/hello-world-test2.ps1 b/blaze-core/src/test/resources/bin/hello-world-test2.ps1 new file mode 100644 index 00000000..b403e397 --- /dev/null +++ b/blaze-core/src/test/resources/bin/hello-world-test2.ps1 @@ -0,0 +1 @@ +Write-Output "Hello World 5624112309877" \ No newline at end of file