#!/usr/bin/env bash

set -e

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

if command -v ktfmt &> /dev/null; then
    echo "==> Running ktfmt"
    ./scripts/kotlin-format
else
    echo "==> Running gradlew formatKotlin"
    ./gradlew formatKotlin
fi

if command -v palantir-java-format &> /dev/null; then
    echo "==> Running palantir-java-format"
    ./scripts/java-format
else
    echo "==> Running gradlew formatJava"
    ./gradlew formatJava
fi
