lib/danger/commands/runner.rb in danger-0.8.5 vs lib/danger/commands/runner.rb in danger-0.9.0
- old
+ new
@@ -1,43 +1,54 @@
module Danger
class Runner < CLAide::Command
- require 'danger/commands/init'
- require 'danger/commands/local'
- require 'danger/commands/plugins/plugin_abstract'
+ require "danger/commands/init"
+ require "danger/commands/local"
- self.summary = 'Run the Dangerfile.'
- self.command = 'danger'
+ # manually set claide plugins as a subcommand
+ require "claide_plugin"
+ @subcommands << CLAide::Command::Plugins
+ CLAide::Plugins.config =
+ CLAide::Plugins::Configuration.new("Danger",
+ "danger",
+ "https://raw.githubusercontent.com/danger/danger.systems/master/plugins-search-generated.json",
+ "https://github.com/danger/danger-plugin-template")
+
+ require "danger/commands/plugins/plugin_lint"
+ require "danger/commands/plugins/plugin_readme"
+
+ self.summary = "Run the Dangerfile."
+ self.command = "danger"
self.version = Danger::VERSION
self.plugin_prefixes = %w(claide danger)
attr_accessor :cork
def initialize(argv)
- dangerfile = argv.option('dangerfile', 'Dangerfile')
+ dangerfile = argv.option("dangerfile", "Dangerfile")
@dangerfile_path = dangerfile if File.exist? dangerfile
- @base = argv.option('base')
- @head = argv.option('head')
- @danger_id = argv.option('danger_id', 'danger')
- @cork = Cork::Board.new(silent: argv.option('silent', false),
- verbose: argv.option('verbose', false))
+ @base = argv.option("base")
+ @head = argv.option("head")
+ @danger_id = argv.option("danger_id", "danger")
+ @cork = Cork::Board.new(silent: argv.option("silent", false),
+ verbose: argv.option("verbose", false))
super
end
def validate!
super
if self.class == Runner && !@dangerfile_path
- help! 'Could not find a Dangerfile.'
+ help! "Could not find a Dangerfile."
end
end
def self.options
[
- ['--base=[master|dev|stable]', 'A branch/tag/commit to use as the base of the diff'],
- ['--head=[master|dev|stable]', 'A branch/tag/commit to use as the head'],
- ['--dangerfile=<path/to/dangerfile>', 'The location of your Dangerfile'],
- ['--danger_id=<id>', 'The identifier of this Danger instance']
+ ["--base=[master|dev|stable]", "A branch/tag/commit to use as the base of the diff"],
+ ["--head=[master|dev|stable]", "A branch/tag/commit to use as the head"],
+ ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
+ ["--danger_id=<id>", "The identifier of this Danger instance"]
].concat(super)
end
def run
env = EnvironmentManager.new(ENV)
@@ -53,21 +64,21 @@
dm.env.ensure_danger_branches_are_setup
# Offer the chance for a user to specify a branch through the command line
ci_base = @base || EnvironmentManager.danger_base_branch
ci_head = @head || EnvironmentManager.danger_head_branch
- dm.env.scm.diff_for_folder('.', from: ci_base, to: ci_head)
+ dm.env.scm.diff_for_folder(".", from: ci_base, to: ci_head)
dm.parse Pathname.new(@dangerfile_path)
post_results dm
dm.print_results
ensure
dm.env.clean_up
end
else
- cork.puts 'Not a Pull Request - skipping `danger` run'
+ cork.puts "Not a Pull Request - skipping `danger` run"
end
end
def post_results(dm)
gh = dm.env.request_source
@@ -79,10 +90,10 @@
def self.report_error(exception)
raise exception if exception.kind_of?(SystemExit)
message = "#{exception.message.red} (#{exception.class.to_s.yellow})"
if exception.backtrace
- danger_lib = File.expand_path('../../..', __FILE__)
+ danger_lib = File.expand_path("../../..", __FILE__)
message << "\n\t" << exception.backtrace.reverse_each.
drop_while { |bt| !bt.start_with?(danger_lib) }.reverse.
join("\n\t")
end
abort(message)