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

19 lines
378 B
Bash
Executable File

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