-
Notifications
You must be signed in to change notification settings - Fork 0
/
install.sh
executable file
·69 lines (57 loc) · 1.02 KB
/
install.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
63
64
65
66
67
68
69
#!/bin/sh
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"
}
_install_go_deps() {
brew install golangci-lint
go install github.com/rakyll/gotest@latest
}
_install_terraform_deps() {
brew install terraform tflint
}
if ! [ -d .git ]; then
_fail "Must run in a git repository!"
exit 1
fi
brew install \
actionlint \
hadolint \
lefthook \
prettier \
shellcheck \
shfmt \
yamllint
BUNDLE_NAME="${1:-lefthook}"
case "$BUNDLE_NAME" in
"lefthook")
_install_go_deps
_install_terraform_deps
;;
"go")
_install_go_deps
;;
"terraform")
_install_terraform_deps
;;
*)
_fail "Unknown bundle name, must be one of \"go\", \"terraform\"."
exit 1
;;
esac
cat <<EOF >.lefthook.yaml
---
remotes:
- git_url: https://github.com/carhartl/lefthook-config
configs:
- $BUNDLE_NAME.yaml
EOF
echo .lefthook.yaml >>.git/info/exclude
lefthook install
_success "Git hooks installed successfully!"