lib/pre-commit/checks/console_log.rb in pre-commit-0.3.1 vs lib/pre-commit/checks/console_log.rb in pre-commit-0.4.0

- old
+ new

@@ -12,24 +12,29 @@ end result end def run - return true if staged_files.empty? + return true if staged_js_files.empty? if detected_bad_code? @error_message = "pre-commit: console.log found:\n" @error_message += instances_of_console_log_violations false else true end end def detected_bad_code? - system("grep -v \/\/ #{staged_files} | grep -qe \"console\\.log\"") + system("grep -v \/\/ #{staged_js_files} | grep -qe \"console\\.log\"") end def instances_of_console_log_violations - `grep -nHe \"console\\.log\" #{staged_files}` + `grep -nHe \"console\\.log\" #{staged_js_files}` end + def staged_js_files + @staged_js_files ||= staged_files.split(" ").select do |file| + File.extname(file) == ".js" + end.join(" ") + end end