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

13 lines
261 B
Plaintext
Raw Normal View History

2023-12-01 22:52:24 +00:00
#!/usr/bin/env bash
set -e
2023-12-03 18:24:45 +00:00
FORMAT_FILES=$(
2023-12-01 22:52:24 +00:00
git --no-pager diff --name-status --no-color --cached | \
awk '$1 != "D" && $2 ~ /\.jsx?$|\.tsx?$/ {print $NF}'
)
2023-12-03 18:32:45 +00:00
if [ -n "$FORMAT_FILES" ]; then
prettier --write "$FORMAT_FILES"
git add "$FORMAT_FILES"
fi