#!/usr/bin/env bash

# Go up the directory tree until you arrive to the git root
while [ ! -d .git ]
do
  cd ../
done

#DON'T RUN THE TEST IF WE ARE IN CONTINUOUS_INTEGRATION ENV
if [ "$TRAVIS" = "true" ]; then
   exit 0
fi

echo -e "Running Unit Tests: \n"

./node_modules/.bin/gulp test

if [ $? -ne 0 ]; then
    echo -e "\033[41mPUSH FAILED:\033[0m Your push contains failing tests. Please fix them and try again.\033[0m"
    exit 1
else 
	echo -e "\033[42mPUSH SUCCEEDED\033[0m"
	exit 0
fi