-
Notifications
You must be signed in to change notification settings - Fork 42
/
precommit.sh
executable file
·62 lines (55 loc) · 1.18 KB
/
precommit.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
set -e
STEP_FORMAT=false
STEP_TEST=false
STEP_BUILD=false
if [[ $# -eq 0 ]] ; then
STEP_FORMAT=true
STEP_TEST=true
STEP_BUILD=true
else
while [[ $# -gt 0 ]]; do
case $1 in
-f)
STEP_FORMAT=true
shift
;;
-t)
STEP_TEST=true
shift
;;
-b)
STEP_BUILD=true
shift
;;
-h)
echo "Command to perform precommit actions."
echo
echo "Usage: precommit.sh [-f] [-t] [-b]"
echo
echo "If no option is specified, then all actions are executed."
echo
echo "Options:"
echo " -f format the files"
echo " -t run unit tests"
echo " -b build the dist"
exit
;;
*)
echo "ERROR: Unknown option '$1'."
exit 1
;;
esac
done
fi
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
GRADLE_CMD="$SCRIPT_DIR/gradlew"
if [[ "$STEP_FORMAT" == "true" ]] ; then
"$GRADLE_CMD" spotlessApply
fi
if [[ "$STEP_TEST" == "true" ]] ; then
"$GRADLE_CMD" :dumper:app:test
fi
if [[ "$STEP_BUILD" == "true" ]] ; then
"$GRADLE_CMD" --parallel :dumper:app:installDist
fi