#!/bin/sh
echo -e "\nValidating Javascript:\n"
# Check for eslint
which tsc &> /dev/null
if [[ "$?" == 1 ]]; then
  echo -e "\t\033[41mPlease install tsc\033[0m"
  exit 1
fi

tsc --noEmit

if [[ "$?" == 0 ]]; then
  echo -e "\033[42mCOMMIT SUCCEEDED\033[0m\n"
  exit 0
else
  echo -e "\033[41mCOMMIT FAILED:\033[0m Your commit contains files that should pass ESLint but do not. Please fix the ESLint errors and try again.\n"
  exit 1
fi