Last active
January 22, 2017 14:07
-
-
Save clinyong/4e18ae44517be6906c9972433d44d7be to your computer and use it in GitHub Desktop.
use tslint to check ts or tsx file before commit
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/sh | |
files=$(git diff --cached --name-only --diff-filter=ACM | grep -E "\.tsx?$") | |
if [ "$files" = "" ]; then | |
exit 0 | |
fi | |
pass=true | |
for file in ${files}; do | |
result=$(./node_modules/.bin/tslint ${file}) | |
if [[ $result != "" ]]; then | |
pass=false | |
echo $result | |
fi | |
done | |
if ! $pass; then | |
echo "\033[91mCOMMIT FAILED:\033[0m Your commit contains files that should pass TSLint but do not. Please fix the TSLint errors and try again." | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment