tabletop-companion/.git-hooks/pre-commit

25 lines
581 B
Plaintext
Raw Permalink Normal View History

2024-05-26 08:11:31 +00:00
#!/usr/bin/env bash
GREEN='\033[0;32m'
AMBER='\033[0;33m'
RED='\033[0;31m'
CLEAR_COLOR='\033[0m'
function run_command {
local COMMAND=$1
local COMMAND_NAME=$2
echo -e "${AMBER}Running $COMMAND_NAME…${AMBER}"
$COMMAND &>/dev/null
if [[ $? -ne 0 ]] ; then
echo -e "${RED}❌ $COMMAND_NAME failed${CLEAR_COLOR}"
exit 1
else
echo -e "${GREEN}✓ $COMMAND_NAME passed${CLEAR_COLOR}"
fi
}
run_command "brakeman --format html -o ../tmp/brakeman.html" "Brakeman"
run_command "bundle exec rubocop" "Rubocop"
run_command "bundle exec rails test" "test suite"