#!/bin/sh

if [ ! -f ".envrc.local" ]; then
  cp .envrc.local.template .envrc.local
  echo ".envrc.local was created from template, please add your credentials and customize to your environment"
fi

if command -v nodenv >/dev/null 2>&1; then
    # installing correct node version using nodenv
    nodenv install -s "$(cat .node-version)"
else
    # alternative using nvm
    # shellcheck source=/dev/null
    . ~/.nvm/nvm.sh
    nvm install "$(cat .node-version)"
fi

# loads personal (secret) data from separate env file (not checked in)
source_env_if_exists .envrc.local