Last active
September 6, 2020 04:52
-
-
Save Gethe/bbcc180770eb9edeebaf83c96844c5df to your computer and use it in GitHub Desktop.
pre-commit Luacheck
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/bash | |
# based on https://gist.github.com/dahjelle/8ddedf0aebd488208a9a7c829f19b9e8 | |
exitCode= | |
for file in $(git diff --cached --name-only | grep -E '\.lua$'); do | |
# we only want to check the staged changes, not any un-staged changes | |
if [[ -f "$file" ]]; then | |
luacheck "$file" --formatter plain | |
fi | |
if [[ $? -eq 1 ]]; then | |
# we want to go through all files before we exit, so just store it for now | |
exitCode=1 | |
fi | |
done | |
exit $exitCode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment