-
Notifications
You must be signed in to change notification settings - Fork 2
/
run.sh
executable file
·53 lines (43 loc) · 896 Bytes
/
run.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
#!/bin/sh
set -eu
readonly DEBUG="${DEBUG:-unset}"
if [ "${DEBUG}" != unset ]; then
set -x
fi
_fail() {
printf "\033[0;31m==> %s\033[0m\n\n" "$1"
}
_success() {
printf "\033[0;32m==> %s\033[0m\n\n" "$1"
}
_info() {
printf "\033[1;33m==> %s\033[0m\n\n" "$1"
}
_user() {
printf "\033[0;33m%s\033[0m" "$1"
}
_setup_git_hooks() {
_user "Do you want to install the Git hooks? (y/n) "
read -r answer
if [ "$answer" = "y" ]; then
if ! command -v lefthook >/dev/null 2>&1; then
_fail "Setup requires Lefthook, please install first: \`brew install lefthook\`"
exit 1
fi
lefthook install
_info "Git hooks installed.."
fi
}
_init() {
_setup_git_hooks
}
_help() {
echo "Usage: ./run.sh [command]"
echo ""
echo "Available commands:"
echo "init Set up repository for development"
}
case "$@" in
"init") _init ;;
*) _help ;;
esac