# http://stackoverflow.com/questions/3474526/stop-on-first-error
set -e

if [ "$CI" = "true" ]
then
  # Codeship checks out the HEAD of the request branch directly, rather than
  # checking out the branch name, which results in a detached HEAD state. This
  # makes other git commands and git-related grunt tasks (e.g. githash) not
  # work nicely. Fix it by explicitly checking out the requested branch.
  git checkout $CI_BRANCH

  # Tell Codeship to cache globally-installed dependencies, so it doesn't take
  # too long to update npm.
  # https://documentation.codeship.com/basic/languages-frameworks/nodejs/#dependency-cache