This repository has been archived by the owner. It is now read-only.
Permalink
Fetching contributors…
Cannot retrieve contributors at this time
executable file 32 lines (25 sloc) 1.19 KB
#!/usr/bin/env ruby
ADDED_OR_MODIFIED = /A|AM|M|^M/
OTHER_RUBY_FILES = %w(Rakefile Gemfile .pre-commit)
changed_files = `git status --porcelain`
.split(/\n/)
.select { |file_name_with_status| file_name_with_status =~ ADDED_OR_MODIFIED }
.map { |file_name_with_status| file_name_with_status.split(" ")[1] }
changed_ruby_files = changed_files
.select { |file_name| File.extname(file_name) == ".rb" or OTHER_RUBY_FILES.include?(file_name) }
.join(" ")
changed_typescript_files = changed_files
.select { |file_name| File.extname(file_name) == ".ts" }
.join(" ")
exit(0) if changed_files.empty?
unless changed_ruby_files.empty? or system("rubocop #{changed_ruby_files}")
puts("\n\n💥 Fix ruby linting errors with `rubocop -a` and stage changed,"\
" or bypass hook with `git commit --no-verify`")
exit($?.exitstatus)
end
unless changed_typescript_files.empty? or system("npm run lint")
puts("\n\n💥 Fix js linting errors with `npm run lintfix` and stage changed,"\
" or bypass hook with `git commit --no-verify`")
exit($?.exitstatus)
end
exit(0)