Created
July 17, 2020 16:14
-
-
Save shannonwells/61af2a797cb26d04980cc5c5ac720365 to your computer and use it in GitHub Desktop.
pre-commit hook for nodejs projects in Typescript and Javascript.
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 | |
export JSNAMES='\.(js|ts)$' | |
export JSNAMES=$(git diff --cached --name-only --diff-filter=ACM | grep -E $JSNAMES) | |
function exit_err() { echo "β π" ; exit 1; } | |
if [[ ! -z $JSNAMES ]] | |
then | |
echo "Examining $JSNAMES" | |
echo $JSNAMES | xargs npm run format || exit_err | |
npm run lint || exit_err | |
echo $JSNAMES | xargs git add | |
else | |
echo "nothing to do π" | |
exit 0 | |
fi | |
echo "β π" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment