Skip to content

Instantly share code, notes, and snippets.

@jordiclariana
Last active January 22, 2016 11:53
Show Gist options
  • Save jordiclariana/4dda8b811fb43ad6d988 to your computer and use it in GitHub Desktop.
Save jordiclariana/4dda8b811fb43ad6d988 to your computer and use it in GitHub Desktop.
Pre commit for scala projects (sergigp review)
#!/bin/bash
declare -A COLORS
COLORS[RED]='\033[0;31m'
COLORS[GREEN]='\033[0;32m'
COLORS[NC]='\033[0m'
COLORS[WHITE]='\033[1m'
# Print a string using colors
# $1 The color
# $2 The colored string
# $3 Extra string not colored
cprint () {
local color="${1}"
shift
echo -e "${COLORS[${color}]}${1}${COLORS[NC]}${2}"
}
cprint WHITE "\nDoing some Checks...\n"
if sbt compile > /dev/null
then
cprint GREEN "- Compiles"
else
cprint RED "- Code not compiles" " (do 'sbt compile' for more information)"
exit 1
fi
if sbt test > /dev/null
then
cprint GREEN "- Tests passing"
else
cprint RED "- Tests do not pass" " (do 'sbt test' for more information)"
exit 1
fi
if sbt scalastyle > /dev/null
then
cprint GREEN "- Code style$" "\nAll Ok, your code will be commited young padawan.\n"
else
cprint RED "- Code Style not ok" " (do 'sbt scalastyle' for more information)"
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment