Skip to content

Commit 1a9bea7

Browse files
committed
only confirm version once
1 parent 5dc52d7 commit 1a9bea7

File tree

1 file changed

+8
-2
lines changed
  • lib/src/main/java/com/diffplug/spotless/protobuf

1 file changed

+8
-2
lines changed

lib/src/main/java/com/diffplug/spotless/protobuf/BufStep.java

+8-2
Original file line numberDiff line numberDiff line change
@@ -75,15 +75,21 @@ static class State implements Serializable {
7575
private static final long serialVersionUID = -1825662356883926318L;
7676
// used for up-to-date checks and caching
7777
final String version;
78-
final transient ForeignExe exe;
78+
79+
// used for executing
80+
private final transient ForeignExe exe;
81+
private transient String exeAbsPath;
7982

8083
State(BufStep step, ForeignExe exe) {
8184
this.version = step.version;
8285
this.exe = Objects.requireNonNull(exe);
8386
}
8487

8588
String format(ProcessRunner runner, String input, File file) throws IOException, InterruptedException {
86-
List<String> args = List.of(exe.confirmVersionAndGetAbsolutePath(), "format", file.getAbsolutePath());
89+
if (exeAbsPath == null) {
90+
exeAbsPath = exe.confirmVersionAndGetAbsolutePath();
91+
}
92+
List<String> args = List.of(exeAbsPath, "format", file.getAbsolutePath());
8793
return runner.exec(input.getBytes(StandardCharsets.UTF_8), args).assertExitZero(StandardCharsets.UTF_8);
8894
}
8995

0 commit comments

Comments
 (0)