Sha256: 777dda07abefb7b2030fb829ef1892e80b9fd264effad716deeceb1ee8f40c02

Contents?: true

Size: 596 Bytes

Versions: 2

Compression:

Stored size: 596 Bytes

Contents

module Overcommit::Hook::PreCommit
  # Runs `csslint` against any modified CSS files.
  #
  # @see https://github.com/CSSLint/csslint
  class CssLint < Base
    MESSAGE_REGEX = /
      ^(?<file>[^:]+):\s
      (?:line\s(?<line>\d+)[^EW]+)?
      (?<type>Error|Warning)
    /x

    def run
      result = execute(command + applicable_files)
      output = result.stdout.chomp
      return :pass if result.success? && output.empty?

      extract_messages(
        output.split("\n").reject(&:empty?),
        MESSAGE_REGEX,
        lambda { |type| type.downcase.to_sym }
      )
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
overcommit-0.27.0 lib/overcommit/hook/pre_commit/css_lint.rb
overcommit-0.26.0 lib/overcommit/hook/pre_commit/css_lint.rb