Skip to content

Commit

Permalink
Initial work resolving .ps1 files automatically and running them via …
Browse files Browse the repository at this point in the history
…powershell.exe automatically
  • Loading branch information
jjlauer committed Jan 21, 2025
1 parent abf6804 commit 4304f0a
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
16 changes: 16 additions & 0 deletions blaze-core/src/test/java/com/fizzed/blaze/system/ExecTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 2 additions & 0 deletions blaze-core/src/test/resources/bin/hello-world-test2
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
echo "Hello World 5624112309877"
1 change: 1 addition & 0 deletions blaze-core/src/test/resources/bin/hello-world-test2.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Write-Output "Hello World 5624112309877"

0 comments on commit 4304f0a

Please sign in to comment.