File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change 1+ #! /usr/bin/env bash
2+
3+ set -euo pipefail
4+
5+ cd " $( dirname " $0 " ) /.."
6+
7+ if [ $# -eq 0 ]; then
8+ echo " Usage: $0 <file-with-paths> [additional-formatter-args...]"
9+ echo " The file should contain one file path per line"
10+ exit 1
11+ fi
12+
13+ FILE_LIST=" $1 "
14+
15+ if [ ! -f " $FILE_LIST " ]; then
16+ echo " Error: File '$FILE_LIST ' not found"
17+ exit 1
18+ fi
19+
20+ if command -v ktfmt-fast-format & > /dev/null; then
21+ echo " Error: ktfmt-fast-format not found"
22+ exit 1
23+ fi
24+
25+ # Process Kotlin files
26+ kt_files=$( grep -E ' \.kt$' " $FILE_LIST " | grep -v ' ./buildSrc/build/' )
27+ kt_files=$( grep -E ' \.kt$' " $FILE_LIST " | grep -v ' ./buildSrc/build/' )
28+ echo " ==> Found $( echo " $kt_files " | wc -l) Kotlin files:"
29+
30+ if [[ -n " $kt_files " ]]; then
31+ echo " ==> will format Kotlin files"
32+ echo " $kt_files " | tr ' \n' ' \0' | xargs -0 ktfmt --kotlinlang-style " $@ "
33+ else
34+ echo " No Kotlin files to format -- expected outcome during incremental formatting"
35+ fi
36+
37+ # TODO(mbudayr): support palantir-java-format
38+ # Process Java files
39+ # grep -E '\.java$' "$FILE_LIST" | grep -v './buildSrc/build/' | tr '\n' '\0' | xargs -0 -r palantir-java-format --palantir --replace "$@"
You can’t perform that action at this time.
0 commit comments