Skip to content

Commit 4ca9da0

Browse files
committed
Allow specifying projects manually via only/except
1 parent 41f2637 commit 4ca9da0

File tree

1 file changed

+20
-12
lines changed

1 file changed

+20
-12
lines changed

Rakefile

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,26 @@ BaseRspecPath = Pathname.new(Dir.pwd)
1212
ReposPath = BaseRspecPath.join('repos')
1313
MAX_PROJECT_NAME_LENGTH = Projects.map(&:length).max
1414

15+
def filter_projects_by_string(string, projects=Projects)
16+
selection = string.split(" ")
17+
projects.select { |project| selection.include?(project.downcase) }
18+
end
19+
20+
def select_projects(options={})
21+
projects =
22+
if only_string = ENV['ONLY']
23+
filter_projects_by_string(only_string)
24+
else
25+
options.fetch(:only, Projects).flatten - Array(options[:except])
26+
end
27+
28+
projects -= filter_projects_by_string(ENV['EXCEPT']) if ENV['EXCEPT']
29+
30+
projects
31+
end
32+
1533
def run_command(command, opts={})
16-
projects = if opts[:except]
17-
Projects - [opts[:except]].flatten
18-
elsif opts[:only]
19-
[opts[:only]].flatten
20-
else
21-
Projects
22-
end
23-
projects.each do |dir|
34+
select_projects(opts).each do |dir|
2435
next if [opts[:except]].flatten.compact.include?(dir)
2536
path = ReposPath.join(dir)
2637
FileUtils.cd(path) do
@@ -43,10 +54,7 @@ def announce(project)
4354
end
4455

4556
def each_project(options = {})
46-
projects = options.fetch(:only, Projects)
47-
projects -= Array(options[:except])
48-
49-
projects.each do |project|
57+
select_projects(options).each do |project|
5058
Dir.chdir("repos/#{project}") do
5159
if options[:silent]
5260
yield project

0 commit comments

Comments
 (0)