-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint.sh
executable file
·48 lines (42 loc) · 1004 Bytes
/
lint.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
#!/bin/sh
CONFIG_FILE=".lint-config.json"
should_run() {
config_name=$1
if [ ! -f $CONFIG_FILE ]; then
return 0
fi
value=$(jq -e ".$config_name" $CONFIG_FILE)
if [ "$value" = "\"disable\"" ]; then
echo "[!] $config_name is disabled"
return 1
fi
return 0
}
if should_run "black"; then
echo "[+] Running black"
black --line-length 120 $@
black_retval=$?
if [ $black_retval -ne 0 ]; then
echo "black failed with exit code $black_retval"
exit $black_retval
fi
fi
if should_run "isort"; then
echo "[+] Running isort"
isort --profile black $@
isort_retval=$?
if [ $isort_retval -ne 0 ]; then
echo "isort failed with exit code $isort_retval"
exit $isort_retval
fi
fi
if should_run "flake8"; then
echo "[+] Running flake8"
flake8 --config /configs/.flake8 $@
flake8_retval=$?
if [ $flake8_retval -ne 0 ]; then
echo "flake8 failed with exit code $flake8_retval"
exit $flake8_retval
fi
fi
exit 0