#!/usr/bin/env bash # setting -e to exit immediately on a command failure. # set -o pipefail sets the exit code of a pipeline to # that of the rightmost command to exit with a non-zero status, # or to zero if all commands of the pipeline exit successfully. # set -u affects variables. When set, a reference to any variable # you haven't previously defined - with the exceptions of $* and $@ - # is an error, and causes the program to immediately exit set -eo pipefail IFS=$'\n\t' # shellcheck source=/dev/null source "$(dirname "$0")/_common.sh" function project_bootstrap() { _setup_env pip install -U pip pip-tools=='7.3.0' # Check if requirements.txt exists, if not, compile it from requirements.in if [ ! -f requirements.txt ]; then pip-compile requirements.in fi # Check if dev-requirements.txt exists, if not, compile it from dev-requirements.in if [ ! -f dev-requirements.txt ]; then pip-compile dev-requirements.in fi pip-sync requirements.txt dev-requirements.txt } function install_precommit_hooks() { if [ ! -d ".git" ]; then git init fi if [ -z "$VIRTUAL_ENV" ]; then echo "warning: you are not in a virtualenv" exit 1 fi pre-commit install } project_bootstrap install_precommit_hooks