Skip to content

Instantly share code, notes, and snippets.

@PranjalAgni
Created February 16, 2021 12:20
Show Gist options
  • Select an option

  • Save PranjalAgni/65614fe269eda217d1d05bde226b4043 to your computer and use it in GitHub Desktop.

Select an option

Save PranjalAgni/65614fe269eda217d1d05bde226b4043 to your computer and use it in GitHub Desktop.
Alternative shell script to husky works with Windows | Linux | MacOS
#!/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