Sha256: 18f5ee82835bc418dd774b55749679e6e0d7de3b4a549c662ff7deda7cf2e069

Contents?: true

Size: 1.36 KB

Versions: 2

Compression:

Stored size: 1.36 KB

Contents

require "danger/plugin_support/plugin_parser"
require "danger/plugin_support/plugin_file_resolver"
require "danger/plugin_support/plugin_linter"

module Danger
  class PluginLint < CLAide::Command::Plugins
    self.summary = "Lints a plugin"
    self.command = "lint"

    attr_accessor :cork

    def initialize(argv)
      @refs = argv.arguments! unless argv.arguments.empty?
      @cork = Cork::Board.new(silent: argv.option("silent", false),
                              verbose: argv.option("verbose", false))
      super
    end

    self.summary = "Lint plugins from files, gems or the current folder. Outputs JSON array representation of Plugins on success."

    self.description = <<-DESC
      Converts a collection of file paths of Danger plugins into a JSON format.
      Note: Before 1.0, it will also parse the represented JSON to validate whether http://danger.systems would
      show the plugin on the website.
    DESC

    self.arguments = [
      CLAide::Argument.new("Paths, Gems or Nothing", false, true)
    ]

    def run
      file_resolver = PluginFileResolver.new(@refs)
      paths = file_resolver.resolve_to_paths

      parser = PluginParser.new(paths, verbose: true)
      parser.parse
      json = parser.to_json

      linter = PluginLinter.new(json)
      linter.lint
      linter.print_summary(cork)

      exit(1) if linter.failed?
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danger-0.10.1 lib/danger/commands/plugins/plugin_lint.rb
danger-0.10.0 lib/danger/commands/plugins/plugin_lint.rb