Class: PreCommit::ConsoleLogCheck

Inherits:
Object
  • Object
show all
Defined in:
lib/pre-commit/checks/console_log_check.rb

Class Method Summary collapse

Class Method Details

.call(staged_files) ⇒ Object



3
4
5
6
7
8
9
# File 'lib/pre-commit/checks/console_log_check.rb', line 3

def self.call(staged_files)
  staged_files.reject! { |f| File.extname(f) != ".js" }
  return if staged_files.empty?
  errors = `#{Utils.grep} -e "console\\.log" #{staged_files.join(" ")} | grep -v \/\/`.strip
  return unless $?.success?
  "console.log found:\n#{errors}"
end