#!/bin/bash

set -eo pipefail

yarn clean
yarn format

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