-
Notifications
You must be signed in to change notification settings - Fork 2
/
setup_frontend_tests
executable file
·56 lines (48 loc) · 1.42 KB
/
setup_frontend_tests
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
#!/bin/bash
# --- BASH CONSTANTS ---------
bold=$(tput bold)
_bold=$(tput sgr0)
red=$(tput setaf 1)
green=$(tput setaf 2)
reset=$(tput sgr0)
# Usage [ --error ] <message_to_log>
function log_message {
if [ "$1" == "--error" ]; then
echo "${red}[eCIS ERROR]${reset} $2"
else
echo "${green}[eCIS LOG]${reset} $1"
fi
}
# Receives two arguments, the first must be the last output of a command ($?),
# and the second, is an optional message to be logged if no errors are found.
function catch_error {
if [ $1 -ne 0 ]; then
echo "${red}[eCIS ERROR]${reset} The last command exited with error $1. Fix it then try again!"
exit $1;
fi
if [ ! -z "$2" ]; then
# Print the message passed as the second parameters
echo "${green}[eCIS LOG]${reset} $2"
else
echo "${green}[eCIS LOG]${reset} done"
fi
}
echo "=========== Starting Feature Toggles Tests Setup ==========="
cd feature-toggles/test
rm -rf node_modules bower_components
if [ ! -e node_modules ]; then
yarn
catch_error $? "Node modules installed with success"
else
log_message "Node modules already installed"
fi
cd ../../
echo "=========== Starting Fronted Tests Setup ==========="
cd frontend/test
rm -rf node_modules bower_components
if [ ! -e node_modules ]; then
yarn
catch_error $? "Node modules installed with success"
else
log_message "Node modules already installed"
fi