-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDangerfile
36 lines (27 loc) · 973 Bytes
/
Dangerfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# frozen_string_literal: true
require 'threat'
# This way we're autoloading all defined plugins for Danger to register
Threat.loader.eager_load_namespace(Threat::Plugins)
refresh_plugins
ENVIRONMENT_MAPPING = {
Danger::RequestSources::LocalOnly => 'local',
Danger::RequestSources::GitHub => 'github'
}.freeze
# This is a simple way to run a plugins only when the Dangerfile is executed in a specific environment
#
# P.S This method is added to the top-level scope of your Dangerfile
def on(environment_name)
return unless ENVIRONMENT_MAPPING[env.request_source.class] == environment_name.to_s
yield
end
# This is a simple way to run only a part of your Dangerfile
#
# P.S This method is added to the top-level scope of your Dangerfile
def workflow(workflow_name)
return if (current_workflow = ENV['DANGER_WORKFLOW']) &&
(workflow_name.to_s != current_workflow)
yield
end
def rake(*tasks)
system("bundle exec rake #{tasks.join(' ')}")
end