Created
February 16, 2021 12:20
-
-
Save PranjalAgni/65614fe269eda217d1d05bde226b4043 to your computer and use it in GitHub Desktop.
Alternative shell script to husky works with Windows | Linux | MacOS
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/sh | |
| RED="\033[1;31m" | |
| GREEN="\033[1;32m" | |
| NC="\033[0m" | |
| linter_exit_code=1 | |
| staged_js_files=$(git diff --cached --diff-filter=d --name-only | grep .js$) | |
| ./node_modules/.bin/eslint $staged_js_files --quiet --fix | |
| linter_exit_code=$? | |
| git add -f $staged_js_files | |
| if [ $linter_exit_code -ne 0 ] | |
| then | |
| echo "${RED} ❌ Linter errors have occurred ( ͡ಥ ͜ʖ ͡ಥ)${NC}" | |
| exit 1 | |
| else | |
| echo "${GREEN} ✔ Eslint did not find any errors [̲̅$̲̅(̲̅ ͡° ͜ʖ ͡°̲̅)̲̅$̲̅]${NC}" | |
| exit 0 | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment