-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlint-check.sh
executable file
·43 lines (35 loc) · 985 Bytes
/
lint-check.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
#!/bin/sh
# Used in .git/hooks/pre-commit with the following code snipet
#
# LINT="$(git rev-parse --show-toplevel)/lint-check.sh"
# $LINT
# if [ $? -ne 0 ]; then
# echo "Not committing do to Lint errors."
# exit 1
# fi
LINT="pocketlint"
cd "$(git rev-parse --show-toplevel)"
CWD=$(pwd)
JSEXCLUDE="jasmine-2\\.0\\.0"
JSPATH=$(git status --porcelain | grep ".*js$" | \
grep -v $JSEXCLUDE | awk '{print $2}')
HTMLPATH=$(git status --porcelain | grep ".*html$" | awk '{print $2}')
CSSPATH=$(git status --porcelain | grep ".*css$" | awk '{print $2}')
PYTHONPATH=$(git status --porcelain | grep ".*py$" | awk '{print $2}')
RESULT=0
if [ ! -z "$JSPATH" ]; then
echo "js: $JSPATH"
$LINT $JSPATH
RESULT=$(($? + $RESULT))
fi
if [ ! -z "$HTMLPATH" ]; then
echo "html: $HTMLPATH"
$LINT $HTMLPATH
RESULT=$(($? + $RESULT))
fi
if [ ! -z "$PYTHONPATH" ]; then
echo "py: $PYTHONPATH"
$LINT $PYTHONPATH
RESULT=$(($? + $RESULT))
fi
exit $RESULT