add pre-commit hook for automatic code formatting with Prettier

This commit is contained in:
Steven Tischer
2026-06-09 17:33:50 +02:00
parent 91eb08a083
commit 72dc3bd852
+11
View File
@@ -0,0 +1,11 @@
#!/bin/sh
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g')
[ -z "$FILES" ] && exit 0
# Prettify all selected files
echo "$FILES" | xargs ./node_modules/.bin/prettier --ignore-unknown --write
# Add back the modified/prettified files to staging
echo "$FILES" | xargs git add
exit 0