bootstrap/specs/phoenix/template/.githooks/pre-commit

25 lines
431 B
Plaintext
Raw Normal View History

#!/usr/bin/env bash
set -e
mixFiles=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.exs?$/ {print $NF}'
)
for path in $mixFiles
do
mix format "$path"
git add "$path"
done
webFiles=$(
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}'
)
for path in $webFiles
do
prettier --write "$path"
git add "$path"
done