Skip to content

Commit 6242da5

Browse files
chore(internal): support running formatters directly
1 parent 94cdfcd commit 6242da5

File tree

4 files changed

+45
-3
lines changed

4 files changed

+45
-3
lines changed

scripts/format

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,18 @@ set -e
44

55
cd "$(dirname "$0")/.."
66

7-
echo "==> Running formatters"
8-
./gradlew format
7+
if command -v ktfmt &> /dev/null; then
8+
echo "==> Running ktfmt"
9+
./scripts/kotlin-format
10+
else
11+
echo "==> Running gradlew formatKotlin"
12+
./gradlew formatKotlin
13+
fi
14+
15+
if command -v palantir-java-format &> /dev/null; then
16+
echo "==> Running palantir-java-format"
17+
./scripts/java-format
18+
else
19+
echo "==> Running gradlew formatJava"
20+
./gradlew formatJava
21+
fi

scripts/java-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
find . -name "*.java" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r palantir-java-format --palantir --replace "$@"

scripts/kotlin-format

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
cd "$(dirname "$0")/.."
6+
7+
find . -name "*.kt" -not -path "./buildSrc/build/*" -print0 | xargs -0 -r ktfmt --kotlinlang-style "$@"

scripts/lint

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,19 @@ set -e
55
cd "$(dirname "$0")/.."
66

77
echo "==> Running lints"
8-
./gradlew lint
8+
9+
if command -v ktfmt &> /dev/null; then
10+
echo "==> Checking ktfmt"
11+
./scripts/kotlin-format --dry-run --set-exit-if-changed
12+
else
13+
echo "==> Running gradlew lintKotlin"
14+
./gradlew lintKotlin
15+
fi
16+
17+
if command -v palantir-java-format &> /dev/null; then
18+
echo "==> Checking palantir-java-format"
19+
./scripts/java-format --dry-run --set-exit-if-changed
20+
else
21+
echo "==> Running gradlew lintJava"
22+
./gradlew lintJava
23+
fi

0 commit comments

Comments
 (0)