-
Notifications
You must be signed in to change notification settings - Fork 680
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* test pre-push hook * test pre-push hook * add prettier pre-push hook to .github/hooks * add git hooks section to readme * actually add the changed files to git --------- Co-authored-by: Rachel <[email protected]>
- Loading branch information
1 parent
f8f2c3c
commit 265cef1
Showing
2 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/sh | ||
git fetch origin main | ||
# Check for changed JavaScript files. | ||
CHANGED_FILES=$(git diff --name-only origin/main...HEAD | grep -E '\.js$|\.jsx$|\.ts$|\.tsx$' || echo "") | ||
# If JavaScript files have changed, run Prettier. | ||
if [ -n "$CHANGED_FILES" ]; then | ||
echo "Fixing the following files:" | ||
echo "$CHANGED_FILES" | ||
|
||
# Run Prettier on the changed files. | ||
echo "$CHANGED_FILES" | xargs npx prettier --write | ||
echo "Adding Prettier changes to commit" | ||
git add . | ||
git commit -m "Apply Prettier formatting" | ||
else | ||
echo "No files to format" | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters