#!/usr/bin/env bash

if ! gem list foreman -i --silent; then
  echo "Installing foreman..."
  gem install foreman
fi

# ----------------------------------------------------------------------
# in case of running with RAILS_ENV=production with assets precompiling!
# ----------------------------------------------------------------------

if [[ -d public/assets ]]; then
  echo
  echo "You have probably precompiled assets for production purpose!"
  echo
  echo "Would you like to remove these assets before running in DEV?"
  echo "-- Press Enter to confirm / Ctrl+C to cancel"
  read
  rm -rf public/assets
  rm -rf tmp/cache
fi

exec foreman start -f Procfile.dev "$@"