#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
set -e
. $DIR/environment.sh
. $DIR/keys.sh

npm test

if [[ ${SONAR_VERSION} && ${SONAR_LOGIN} && ${SONAR_VERSION} && ${CI_JOB_NAME} = test ]]; then
  sonar-scanner -Dsonar.host.url=${SONAR_URL} -Dsonar.login=${SONAR_LOGIN} -Dsonar.branch=${CI_COMMIT_REF_NAME} -Dsonar.projectVersion=${SONAR_VERSION}
fi

. $DIR/unset.sh
