Sha256: 19310c79de23215d42f69129e1296b18ea9c628661b7d5350ecad3aaa834f165

Contents?: true

Size: 704 Bytes

Versions: 3

Compression:

Stored size: 704 Bytes

Contents

class ConsoleLog

  attr_accessor :staged_files, :error_message

  def self.call(quiet=false)
    check = new
    check.staged_files = Utils.staged_files('public/javascripts')

    result = check.run
    if !quiet && !result
      puts check.error_message
    end
    result
  end

  def run
    return true if staged_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 -q 'console.log' #{staged_files}")
  end

  def instances_of_console_log_violations
    `grep -nH 'console.log' #{staged_files}`
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
pre-commit-0.1.4 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.3 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.2 lib/pre-commit/checks/console_log.rb