forked from johncar/al_ui_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-push
executable file
·59 lines (50 loc) · 1.53 KB
/
pre-push
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
#!/bin/sh
#
# Pre-push hooks
# Set up term colors
blue='\033[1;36m'
green='\033[1;32m'
red='\033[0;31m'
white='\033[1;37m'
yellow='\033[1;33m'
NC='\033[0m' # No Color
WHERE_AM_I=`pwd`
# Iterate up the directory structure until we find the root of the al_ui_template repo that we are being executed within
while [[ $PWD != '/' && ! ( -f "$PWD/package.json" && -f "$PWD/bower.json" && "$PWD/karma.conf.js" ) ]]; do
if [[ -d .git && -f .git/aluitemplate-link ]]
then
cd $(<.git/aluitemplate-link)
else
cd ..
fi
done
if [ $PWD = '/' ]
then
echo "The root of the current al_ui_template repository could not be found: \033[1;31mABORTING\033[0m (make sure you run npm hookmeup)"
echo "Evaluated from this path: $WHERE_AM_I"
exit 1
fi
if [ ! -f package.json ]
then
echo "The root of your al_ui_template repository does not actually appear to be an al_ui_template repository: \033[1;31mABORTING\033[0m"
echo "Using al_ui_template root $PWD derived from origin path $WHERE_AM_I"
exit 1
fi
local_branch=$(git branch | sed -n -e 's/^\* \(.*\)/\1/p')
echo "=================================================================="
echo "Testing local branch \033[1;36m$local_branch\033[0m..."
echo "=================================================================="
# Lint all code
npm run lint
HINTRESULT=$?
[ $HINTRESULT -ne 0 ] && exit 1
# Run tests
npm run unit-tests all
TESTRESULT=$?
[ $TESTRESULT -ne 0 ] && exit 1
# Build LESS
npm run less
LESSRESULT=$?
[ $LESSRESULT -ne 0 ] && exit 1
cd $WHERE_AM_I
exit 0