Created
August 9, 2017 09:10
-
-
Save aalin/68167bada0f90e9a2175a23b985dc31b to your computer and use it in GitHub Desktop.
Run prettier on staged files
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
#!/bin/bash | |
prettier=$(npm bin)/prettier | |
git diff --cached --name-status src/ | while read -r status filename; do | |
# skip deleted files | |
if [[ "$status" == "D" ]]; then continue; fi | |
if [[ "$filename" =~ \.jsx?$ ]]; then | |
"$prettier" --single-quote --no-bracket-spacing --write "$filename" || exit 1 | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment