#!/bin/bash

# $ yarn test <testcase_name>
#
# Run test cases which file name partially matches the given name
# To run skipped test (skip-*.ts), need to specify full name

set -eo pipefail

yarn clean
yarn format

if [[ $1 == "--watch" ]]; then
  tsc-watch --onSuccess "yarn _compile_success $2" --onFailure "yarn _compile_failure"
else
  yarn compile:typescript && yarn _compile_success $1 || yarn _compile_failure
  echo "Note: run 'yarn test --watch [test]' to enable watch mode"
fi
