-
-
Notifications
You must be signed in to change notification settings - Fork 114
/
setup-env.sh
executable file
·44 lines (38 loc) · 904 Bytes
/
setup-env.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
#!/bin/bash
SCRIPT_DIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "`dirname "$0"`"
PRE_COMMIT=${SCRIPT_DIR}/.venv/bin/pre-commit
pre_commit() {
# Set up pre-commit hook
if [ ! -f "${PRE_COMMIT}" ]; then
pushd ${SCRIPT_DIR}
python3 -m venv .venv
.venv/bin/pip install pre-commit
popd
fi
${PRE_COMMIT} install
}
remove_pre_commt() {
if [ -f "${PRE_COMMIT}" ]; then
${PRE_COMMIT} uninstall
fi
}
if [ $# -eq 0 ]; then
set -- --help
fi
for arg in "$@"; do
case $arg in
pre_commit | pre-commit | install_pre_commit | install-pre-commit)
pre_commit
;;
remove_pre_commit | remove-pre-commit | uninstall_pre_commit | uninstall-pre-commit)
remove_pre_commit
;;
*)
echo "USAGE $0 [commands]"
echo " Commands:"
echo " install-pre-commit - installs pre-commit hooks"
echo " uninstall-pre-commit - removes pre-commit hooks"
;;
esac
done