Sha256: 1d0e67401d854c08236c4fd758026532484b56acc03661fa1bd2b36930605863

Contents?: true

Size: 596 Bytes

Versions: 4

Compression:

Stored size: 596 Bytes

Contents

module Overcommit::GitHook
  class JSConsoleLog < HookSpecificCheck
    include HookRegistry
    file_type :js

    # https://www.pivotaltracker.com/story/show/18119495
    def run_check
      paths = staged.map { |s| s.path }.join(' ')
      output = `grep -n -e 'console\\.log' #{paths}`.split("\n").reject do |line|
        /^\d+:\s*\/\// =~ line ||     # Skip comments
          /ALLOW_CONSOLE_LOG/ =~ line # and lines with ALLOW_CONSOLE_LOG
      end.join("\n")
      staged.each { |s| output = s.filter_string(output) }
      return (output.empty? ? :good : :bad), output
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
overcommit-0.1.11 lib/overcommit/plugins/pre_commit/js_console_log.rb
overcommit-0.1.10 lib/overcommit/plugins/pre_commit/js_console_log.rb
overcommit-0.1.9 lib/overcommit/plugins/pre_commit/js_console_log.rb
overcommit-0.1.8 lib/overcommit/plugins/pre_commit/js_console_log.rb