-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #91 from Serhii-DV/dev
Version 0.15.0
- Loading branch information
Showing
18 changed files
with
536 additions
and
196 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 |
---|---|---|
@@ -1,10 +1,25 @@ | ||
#!/bin/sh | ||
# Run prettier on staged files | ||
# Run Prettier only on staged files | ||
|
||
npm run prettier:fix | ||
# Get a list of staged files that match JavaScript, TypeScript, or other file extensions you want to format | ||
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep -E '\.(js|jsx|ts|tsx|css|scss|html|md)$') | ||
|
||
# If there are no staged files that need Prettier, exit early | ||
if [ -z "$STAGED_FILES" ]; then | ||
echo "No staged files to format." | ||
exit 0 | ||
fi | ||
|
||
# Run Prettier on the staged files | ||
echo "Running Prettier on staged files..." | ||
echo "$STAGED_FILES" | xargs npx prettier --write | ||
|
||
# Re-add the formatted files to the staging area | ||
echo "$STAGED_FILES" | xargs git add | ||
|
||
# Check if Prettier made changes | ||
if [ -n "$(git diff --name-only --cached)" ]; then | ||
if [ -n "$(git diff --cached --name-only)" ]; then | ||
echo "Prettier has fixed files. Please review the changes." | ||
git add . | ||
else | ||
echo "No changes were made by Prettier." | ||
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
Oops, something went wrong.