Skip to content

Instantly share code, notes, and snippets.

@iamricks
Last active January 19, 2022 17:16
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 iamricks/dc7530bfa0aef3bbd4a7fad3c72d5899 to your computer and use it in GitHub Desktop.
Save iamricks/dc7530bfa0aef3bbd4a7fad3c72d5899 to your computer and use it in GitHub Desktop.
Find syntax errors before pushing to git, good for avoiding a push to Heroku that takes down production ;)
# Find files modified
# Only works before git add
modified_file_paths = %x(git diff --name-only).split("\n")
# Make sure zeitwerk doesn't surprise you
print(%x(bin/rails zeitwerk:check))
# Loop through files and check syntax, print status
modified_file_paths.each do |path|
next if !path.include?('.rb')
print(%x(ruby -c #{path}))
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment