Guest User

Untitled

a guest
Nov 10th, 2016
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. files=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$")
  4. if [ "$files" == "" ]; then
  5. exit 0
  6. fi
  7.  
  8. flow=$(npm run flow) # Change this to your flow script in package.json
  9. eslint=$PWD/node_modules/.bin/eslint
  10.  
  11. flowfiles=""
  12. flowerrors="false"
  13. lintfiles=""
  14. linterrors="false"
  15.  
  16. for file in ${files}; do
  17. if [[ "$flow" == *"$file"* ]]; then
  18. flowfiles+="\n$file"
  19. flowerrors="true"
  20. fi
  21. done
  22.  
  23. for file in ${files}; do
  24. lint=$($eslint -c .eslintrc ${file})
  25. if [[ "$lint" == *"problem"* ]]; then
  26. lintfiles+="\n$file"
  27. linterrors="true"
  28. fi
  29. done
  30.  
  31. if [ "$flowerrors" == "true" ]; then
  32. echo "$flow"
  33. echo "\n\033[41m COMMIT FAILED: \033[0m Your commit contains flow errors in: $flowfiles"
  34. fi
  35.  
  36. if [ "$linterrors" == "true" ]; then
  37. $eslint -c .eslintrc ${files}
  38. echo "\n\033[41m COMMIT FAILED: \033[0m Your commit contains lint errors and/or warnings in: $lintfiles"
  39. fi
  40.  
  41. if [ "$flowerrors" == "true" ] || [ "$linterrors" == "true" ] ; then
  42. exit 1
  43. fi
Advertisement
Add Comment
Please, Sign In to add comment