blob: 1ade050a8c61ccac821f8e3657b46f9c4fb7365d [file] [log] [blame]
Alan Viverette01484c12022-07-01 11:17:41 -04001#!/bin/bash
2
3function usage() {
Jeff Gastona6d84c82022-10-19 17:02:46 -04004echo "usage: $0 [--skip-if-empty] <gradle_arguments>"
Alan Viverette01484c12022-07-01 11:17:41 -04005echo
6echo "Runs the ktlint Gradle task with the provided gradle_arguments, if any of the files to check with .kt(s). Specify files to check using --file=<path> arguments."
Jeff Gastona6d84c82022-10-19 17:02:46 -04007echo
8echo "--skip-if-empty: don't output a usage error if no arguments are provided"
Alan Viverette01484c12022-07-01 11:17:41 -04009exit 1
10}
11
12if [ "$1" == "" ]; then
13usage
14fi
15
Jeff Gastona6d84c82022-10-19 17:02:46 -040016if [ "$1" == "--skip-if-empty" ]; then
17shift
18fi
19
Alan Viverette01484c12022-07-01 11:17:41 -040020PROJECT_ROOT=$(dirname "$0")/..
21
22if echo "$@" | tr ' ' '\n' | grep -q "^--file=.\+\.kts\?$"; then
23exec "$PROJECT_ROOT"/gradlew -q -p "$PROJECT_ROOT" --continue :ktlintCheckFile --configuration-cache "$@"
24fi