Sha256: 06b880fc0b8572f5acee93010e46b0bce77cf24a4dbb43099503090e87f88bf7

Contents?: true

Size: 874 Bytes

Versions: 21

Compression:

Stored size: 874 Bytes

Contents

# frozen_string_literal: true

module Overcommit::Hook::PreCommit
  # Runs `mdl` against any modified Markdown files
  #
  # @see https://github.com/mivok/markdownlint
  class Mdl < Base
    def run
      result = execute(command, args: applicable_files)
      output = result.stdout.chomp

      return :pass if result.success?
      return [:fail, result.stderr] unless result.stderr.empty?

      # example message:
      #   [{"filename":"file1.md","line":1,"rule":"MD013","aliases":["line-length"],
      #   "description":"Line length"}]
      json_messages = JSON.parse(output)
      json_messages.map do |message|
        Overcommit::Hook::Message.new(
          :error,
          message['filename'],
          message['line'],
          "#{message['filename']}:#{message['line']} #{message['rule']} #{message['description']}"
        )
      end
    end
  end
end

Version data entries

21 entries across 21 versions & 2 rubygems

Version Path
overcommit-0.64.1 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.64.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.63.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.62.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.61.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.60.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.59.1 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.59.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-jeygeethanmedia-0.58.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.58.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.57.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.56.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.55.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.54.1 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.54.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-jeygeethanmedia-0.53.1.2 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-jeygeethanmedia-0.53.1.1 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-jeygeethanmedia-0.53.1 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.53.0 lib/overcommit/hook/pre_commit/mdl.rb
overcommit-0.52.1 lib/overcommit/hook/pre_commit/mdl.rb