Skip to content

Commit ae75240

Browse files
committed
Input distinct shell file path
1 parent 62fcf4e commit ae75240

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

lib/src/main/java/com/diffplug/spotless/shell/ShfmtStep.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
import java.util.List;
2323
import java.util.Objects;
2424
import java.util.regex.Pattern;
25+
import java.util.stream.Collectors;
26+
import java.util.stream.Stream;
2527

2628
import javax.annotation.Nullable;
2729

@@ -98,10 +100,11 @@ static class State implements Serializable {
98100

99101
String format(ProcessRunner runner, String input, File file) throws IOException, InterruptedException {
100102
if (args == null) {
101-
args = List.of(exe.confirmVersionAndGetAbsolutePath());
103+
args = List.of(exe.confirmVersionAndGetAbsolutePath(), "--filename");
102104
}
103-
104-
return runner.exec(input.getBytes(StandardCharsets.UTF_8), args).assertExitZero(StandardCharsets.UTF_8);
105+
final List<String> finalArgs = Stream.concat(args.stream(), Stream.of(file.getAbsolutePath()))
106+
.collect(Collectors.toList());
107+
return runner.exec(input.getBytes(StandardCharsets.UTF_8), finalArgs).assertExitZero(StandardCharsets.UTF_8);
105108
}
106109

107110
FormatterFunc.Closeable toFunc() {

0 commit comments

Comments
 (0)