#!/bin/bash

tps_dir=$(pwd)
echo "tps dir: $tps_dir"

echo """
##############################
docker container clean up
##############################
"""

docker system prune -f

# Run core tests
if [[ "$INIT_ONLY" != '1' ]];
then
    echo """
##############################
Running core tests
##############################
"""

    sudo npm run --silent test:core -- $@ || exit 1
fi

echo """
##############################
Running init tests
##############################
"""
# Run init tests
# Init tests need to be ran in docker container 
# this way they can have there own enviroment to mess up
# TODO: had this before    
# maybe remove to test init with global?
docker run \
    -t \
    --env "TEST_DIR=/root/app/" \
    -v "$tps_dir/__tests__/.tps:/root/app/.tps" \
    -v "$tps_dir:/root/app/templates" \
    -w "/root/app/templates" \
    node \
    npm run test:run:init -- $@
    # -v "$tps_dir/__tests__/.tps-global:/root/.tps" \