Skip to content

Instantly share code, notes, and snippets.

@Gethe
Last active September 6, 2020 04:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Gethe/bbcc180770eb9edeebaf83c96844c5df to your computer and use it in GitHub Desktop.
Save Gethe/bbcc180770eb9edeebaf83c96844c5df to your computer and use it in GitHub Desktop.
pre-commit Luacheck
#!/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