Skip to content

Commit 1ae4f03

Browse files
committed
Minor fixes to run script
1 parent 6b9febb commit 1ae4f03

1 file changed

Lines changed: 24 additions & 13 deletions

File tree

‎run‎

Lines changed: 24 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,15 @@
22

33
NOCOLOR='\033[0m'
44
GREEN='\033[0;32m'
5-
ORANGE='\033[0;33m'
5+
ORANGE='\033[38;5;208m' # 256-colour palette orange, ANSI 33 is yellow
6+
GRAY='\e[2;37m'
7+
BLACK="\033[0;30m" # Black
8+
RED="\033[0;31m" # Red
9+
YELLOW="\033[0;33m" # Yellow
10+
BLUE="\033[0;34m" # Blue
11+
PURPLE="\033[0;35m" # Purple
12+
CYAN="\033[0;36m" # Cyan
13+
WHITE="\033[0;37m" # White
614
BOLD=$(tput bold)
715
NORMAL=$(tput sgr0)
816

@@ -19,12 +27,15 @@ SUPPORTED_COMMANDS=(
1927
# This disables twig caching and activate debugging tools
2028
export DEV_MODE=true
2129

22-
function ctrl_c() {
23-
if [ $# -gt 0 ];
30+
# Stop browser-sync when the script exits (Ctrl-C on the PHP server included)
31+
BROWSER_SYNC_PID=''
32+
function cleanup() {
33+
if [ -n "${BROWSER_SYNC_PID}" ];
2434
then
25-
pkill browser-sync
35+
kill "${BROWSER_SYNC_PID}" 2> /dev/null
2636
fi
2737
}
38+
trap cleanup EXIT
2839

2940
if [ $# -gt 0 ]
3041
then
@@ -53,27 +64,29 @@ then
5364
echo -e " ${BOLD}run status${NORMAL} Check if the current commit is on production"
5465
echo ""
5566
echo "Additional parameters will be ignored."
56-
exit 1
67+
exit 0
5768
fi
5869

5970
if [ $# -gt 0 ] && [ $1 = 'tests' ]
6071
then
6172
composer test:all
62-
exit 1
73+
exit $?
6374
fi
6475

6576
if [ $# -gt 0 ] && [ $1 = 'status' ]
6677
then
6778
local=`git rev-parse master`
79+
dev=`curl -s https://dev.whattrainisitnow.nonprod.webservices.mozgcp.net/deployed-version.txt`
6880
prod=`curl -s https://whattrainisitnow.com/deployed-version.txt`
6981
echo -e "$GREEN""Checking if the latest commit is what we have in production""$NORMAL"
70-
echo "Local : $local"
71-
echo -n "Prod : $prod"
82+
echo -e "$GRAY""Dev $dev""$NORMAL"
83+
echo "Local $local"
84+
echo -n "Prod $prod"
7285
if [ $local == $prod ]
7386
then
7487
echo ""
7588
echo -en "$GREEN""Yes, we are good""$NORMAL"
76-
elif [[ condition ]]; then
89+
else
7790
x=$(($(git rev-list --count $prod..$local)))
7891
echo ""
7992
if [ $x == 1 ]
@@ -83,7 +96,7 @@ then
8396
echo -en "$ORANGE""No, production is $x commits behind""$NORMAL"
8497
fi
8598
fi
86-
exit 1
99+
exit 0
87100
fi
88101

89102
echo -e "${GREEN}${BOLD}Launching PHP development server on http://${SERVER}${NORMAL}${NOCOLOR}"
@@ -93,12 +106,10 @@ if command -v browser-sync &> /dev/null; then
93106
then
94107
echo -e "${GREEN}browser-sync is installed on the system, launching it in the background${NOCOLOR}"
95108
browser-sync start --proxy "localhost:8082" --files "**/*" &
109+
BROWSER_SYNC_PID=$!
96110
else
97111
echo -e "${ORANGE}browser-sync is installed on the system but won't be launched${NOCOLOR}"
98112
fi
99113
fi
100114

101115
php -d opcache.jit=disable -S ${SERVER} -t public/ app/inc/router.php
102-
103-
# trap ctrl-c and call ctrl_c()
104-
trap ctrl_c INT

0 commit comments

Comments
 (0)