Sha256: 9f2ca31e8aa6c70a743b0bae28801a970f0ca36d307a54d056c8184b7524649b

Contents?: true

Size: 729 Bytes

Versions: 14

Compression:

Stored size: 729 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 -v \/\/ #{staged_files} | grep -qe \"console\\.log\"")
  end

  def instances_of_console_log_violations
    `grep -nHe \"console\\.log\" #{staged_files}`
  end

end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
pre-commit-0.3.1 lib/pre-commit/checks/console_log.rb
pre-commit-0.3.0 lib/pre-commit/checks/console_log.rb
pre-commit-0.2.0 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.19 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.18 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.17 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.16 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.15 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.14 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.13 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.12 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.11 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.10 lib/pre-commit/checks/console_log.rb
pre-commit-0.1.9 lib/pre-commit/checks/console_log.rb