Created
February 14, 2018 22:15
-
-
Save johngrimes/843b435def6cfb59ce826b009a7e9894 to your computer and use it in GitHub Desktop.
Format staged files with Prettier before commit
This file contains hidden or 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 | |
STAGED=$(git diff --name-only --cached --diff-filter=AM | egrep '^(.*).(js|json|css)$') | |
yarn prettier --write $STAGED | |
git add $STAGED |
This file contains hidden or 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
{ | |
"name": "my-app", | |
"version": "0.1.0", | |
"dependencies": {}, | |
"devDependencies": { | |
"pre-commit": "^1.2.2", | |
"prettier": "^1.10.2" | |
}, | |
"scripts": { | |
"format-staged": "bash scripts/formatStagedFiles.sh" | |
}, | |
"pre-commit": ["lint", "format-staged", "test"] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment