Add pre-commit hook to check code formatting

This commit is contained in:
Zachary Dunn 2019-09-01 22:58:20 +00:00
parent 3075d4a5b1
commit 0c3ee653b6
1 changed files with 11 additions and 0 deletions

11
git-hooks/pre-commit Executable file
View File

@ -0,0 +1,11 @@
#!/bin/sh
FORMAT_COMMAND="mix format"
PATHS="mix.exs lib/**/*.{ex,exs} test/**/*.{ex,exs}"
TEST_FORMAT_COMMAND="$FORMAT_COMMAND --check-formatted $PATHS"
if ! $($TEST_FORMAT_COMMAND > /dev/null 2>&1); then
echo "You have unformatted files.\nRun \`$FORMAT_COMMAND $PATHS\`"
exit 1
fi