forked from aaronlord/laroute
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-tests.sh
executable file
·55 lines (50 loc) · 1.31 KB
/
run-tests.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
#!/usr/bin/env bash
# GET SCRIPT PATH
SOURCE="${BASH_SOURCE[0]}"
# Resolve $SOURCE until the file is no longer a symlink
while [[ -h "$SOURCE" ]]; do
DIR="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
SOURCE="$(readlink "$SOURCE")"
# if $SOURCE was a relative symlink, we need to resolve it relative
# to the path where the symlink file was located
[[ ${SOURCE} != /* ]] && SOURCE="$DIR/$SOURCE"
done
SCRIPT_PATH="$( cd -P "$( dirname "$SOURCE" )" >/dev/null 2>&1 && pwd )"
if [[ -z "$SCRIPT_PATH" ]] ; then
exit 1 # fail
fi
# CD TO SCRIPT PATH
cd ${SCRIPT_PATH}
# CHECK TEST DEPENDENCIES
if ! hash grunt; then
echo "You must have grunt-cli installed!"
exit 1
fi
if [[ ! -f ./composer.phar ]] && ! hash composer; then
echo "You must have composer installed or PHP and composer.phar!"
exit 1
fi
if ! hash npm; then
echo "You must have npm installed!"
exit 1
fi
# GET TOOLS PATHS
if [[ -f ./composer.phar ]]; then
if ! hash php; then
echo "You must have PHP installed!"
exit 1
fi
PHP_BIN=$(which php)
COMPOSER_BIN="$PHP_BIN ./composer.phar"
else
COMPOSER_BIN=$(which composer)
fi
GRUNT_BIN=$(which grunt)
NPM_BIN=$(which npm)
# RUN TESTS
# Uglify/minify JS template file
${GRUNT_BIN}
# Run PHP tests
${COMPOSER_BIN} test
# Run JS tests
${NPM_BIN} test