Skip to content

Commit

Permalink
Input distinct shell file path
Browse files Browse the repository at this point in the history
  • Loading branch information
Goooler committed Feb 2, 2024
1 parent 62fcf4e commit ae75240
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/src/main/java/com/diffplug/spotless/shell/ShfmtStep.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.List;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.stream.Stream;

import javax.annotation.Nullable;

Expand Down Expand Up @@ -98,10 +100,11 @@ static class State implements Serializable {

String format(ProcessRunner runner, String input, File file) throws IOException, InterruptedException {
if (args == null) {
args = List.of(exe.confirmVersionAndGetAbsolutePath());
args = List.of(exe.confirmVersionAndGetAbsolutePath(), "--filename");
}

return runner.exec(input.getBytes(StandardCharsets.UTF_8), args).assertExitZero(StandardCharsets.UTF_8);
final List<String> finalArgs = Stream.concat(args.stream(), Stream.of(file.getAbsolutePath()))
.collect(Collectors.toList());
return runner.exec(input.getBytes(StandardCharsets.UTF_8), finalArgs).assertExitZero(StandardCharsets.UTF_8);
}

FormatterFunc.Closeable toFunc() {
Expand Down

0 comments on commit ae75240

Please sign in to comment.