#!/usr/bin/env bash

source_local() {
  file=./.envrc.local
  if [[ -f "$file" ]]; then
    source_env $file
  fi
  watch_file $file
}

source_local

if [[ "$CI" != "true" && (-z "$GITHUB_TOKEN" || -z "$CIRCLE_API_USER_TOKEN") ]]; then
  yellow=`tput setaf 3`
  reset=`tput sgr0`
  echo "${yellow}please set GITHUB_TOKEN and CIRCLE_API_USER_TOKEN env variables in .envrc.local file if you wish to release turtle-cli"
  echo "run 'cp .envrc.local.example .envrc.local' if you don't have one yet and edit the new file${reset}"
fi

export NODE_ENV=development

export EXPO_TURTLE_TOOLS_DIR="$(pwd)/tools"

PATH_add $EXPO_TURTLE_TOOLS_DIR/bin
if [ "$CI" = "true" ] && [[ ! $OSTYPE =~ darwin.* ]]; then
  PATH_add $EXPO_TURTLE_TOOLS_DIR/ci/bin
fi
