actions-test/hooks/pre-commit

13 lines
352 B
Text
Raw Permalink Normal View History

2024-02-22 15:32:55 +01:00
#!/bin/sh
# adapted from https://prettier.io/docs/en/precommit.html#option-5-shell-script
FILES=$(git diff --cached --name-only --diff-filter=ACMR | sed 's| |\\ |g' | grep '.dart$')
[ -z "$FILES" ] && exit 0
2023-12-22 20:27:26 +01:00
2024-02-22 15:32:55 +01:00
# Format all selected files
echo "$FILES" | xargs dart format
# Add back the formatted files to staging
echo "$FILES" | xargs git add
exit 0