Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/dev/jbang/cli/Edit.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ private boolean openEditor(String projectPathString, List<String> additionalFile
cmd = new String[] { "cmd", "/c", editorCommand };
}
verboseMsg("Running `" + String.join(" ", cmd) + "`");
new ProcessBuilder(cmd).start();
Util.run(new ProcessBuilder(cmd));
}
return true;
}
Expand Down Expand Up @@ -366,7 +366,7 @@ private static void setupEditor(Path editorBinPath, Path dataPath) throws IOExce
"--install-extension", "vscjava.vscode-java-dependency",
"--install-extension", "jbangdev.jbang-vscode");
pb.inheritIO();
Process process = pb.start();
Process process = Util.run(pb);
try {
int exit = process.waitFor();
if (exit > 0) {
Expand Down
1 change: 1 addition & 0 deletions src/main/java/dev/jbang/cli/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ public Integer doCall() throws IOException {
String cmdline = updateGeneratorForRun(genb).build().generate();

Util.verboseMsg("run: " + cmdline);
Util.infoMsg(cmdline);
realOut.println(cmdline);

return EXIT_EXECUTE;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ protected void runCompiler(List<String> optionList) throws IOException {
}

protected void runCompiler(ProcessBuilder processBuilder) throws IOException {
Process process = processBuilder.start();
Process process = Util.run(processBuilder);
try {
process.waitFor();
} catch (InterruptedException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ protected void runNativeBuilder(List<String> optionList) throws IOException {
Util.infoMsg("log: " + nilog.toString());
pb.redirectOutput(nilog.toFile());

Process process = pb.start();
Process process = Util.run(pb);
try {
process.waitFor();
} catch (InterruptedException e) {
Expand Down
5 changes: 2 additions & 3 deletions src/main/java/dev/jbang/spi/IntegrationManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -261,9 +261,8 @@ protected IntegrationResult runIntegrationExternal(IntegrationInput input,
Util.verboseMsg("Input: " + parser.toJson(input));
}

Process process = new ProcessBuilder(args)
.redirectError(ProcessBuilder.Redirect.INHERIT)
.start();
Process process = Util.run(new ProcessBuilder(args)
.redirectError(ProcessBuilder.Redirect.INHERIT));

try (Writer w = new BufferedWriter(new OutputStreamWriter(process.getOutputStream()))) {
parser.toJson(input, w);
Expand Down
7 changes: 6 additions & 1 deletion src/main/java/dev/jbang/util/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,11 @@ static class History {
String version;
}

public static Process run(ProcessBuilder pb) throws IOException {
infoMsg(String.join(" ", pb.command()));
return pb.start();
}

/**
* Runs the given command + arguments and returns its output (both stdout and
* stderr) as a string
Expand All @@ -1496,7 +1501,7 @@ public static String runCommand(String... cmd) {
try {
ProcessBuilder pb = CommandBuffer.of(cmd).asProcessBuilder();
pb.redirectErrorStream(true);
Process p = pb.start();
Process p = Util.run(pb);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String cmdOutput = br.lines().collect(Collectors.joining("\n"));
int exitCode = p.waitFor();
Expand Down
Loading