#!/bin/env bash

if [[ $(hostname) != "ladd76" ]]; then
  echo >&2 "host $(hostname) != 'ladd76'"
  exit 1
fi

set -eo pipefail

git checkout dev
./sync
if git diff; then
  git add .
  git commit "$@"
  git push
fi
ssh lentilz "
  set -oe pipefail
  export NVM_DIR=\"\$HOME/.nvm\"
  [ -s \"\$NVM_DIR/nvm.sh\" ] && \. \"\$NVM_DIR/nvm.sh\"  # This loads nvm
  cd ~/code/gravity-dev
  git add .
  git stash
  git pull
  git stash apply
  npm i
"
echo >&2
echo >&2 "Committed and deployed to https://laddhoffman.com/gravity-dev/"
