Created
January 25, 2018 21:06
-
-
Save mattjared/f06f6afa908f523d95a951d36d1dec00 to your computer and use it in GitHub Desktop.
stylelint precommit hook to auto fix things that can be fixed
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
if [[ "$STAGED_FILES_CSS" != "" ]]; then | |
echo -e "\nValidating Styles:\n" | |
# Loop through the staged stylesheets | |
for FILE in $STAGED_FILES_CSS | |
do | |
"$STYLELINT" "$FILE" | |
if [[ "$?" == 0 ]]; then | |
echo -e "\t\033[32mStyleLint Passed: $FILE\033[0m" | |
else | |
echo -e "\t\033[41mStyleLint Failed: $FILE\033[0m" | |
PASS=false | |
echo -e "\t\033[41mAttempting Fix: $FILE\033[0m" | |
"$STYLELINT" "$FILE" --fix | |
if [[ "$?" == 0 ]]; then | |
echo -e "\t\033[32mStyleLint Passed: $FILE\033[0m" | |
FIX=true | |
else | |
echo -e "\t\033[41mStyleLint Failed: $FILE\033[0m" | |
FIX=false | |
fi | |
fi | |
done | |
echo -e "\nStyles validation completed\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment