Skip to content

Commit

Permalink
Merge pull request #14 from Arepo/recursive_find
Browse files Browse the repository at this point in the history
Recursive find
  • Loading branch information
sgerrand authored Oct 17, 2016
2 parents b1d5a99 + b12368f commit 7c253d2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
hellgrid (0.0.1)
hellgrid (0.2.0)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -30,4 +30,4 @@ DEPENDENCIES
rspec (~> 3.4, >= 3.4.0)

BUNDLED WITH
1.11.2
1.12.5
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ Executing:
hellgrid /path/to/root/dir
```

To search recursively (should you have nested projects), use the `-r ` flag:
```
hellgrid -r /path/to/root/dir
```

Should result in:
```bash
x | bar | foo
Expand Down
3 changes: 2 additions & 1 deletion bin/hellgrid
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ require 'find'

require 'hellgrid'

recursive_search = !!(ARGV.delete('-r'))
folders = ARGV.empty? ? [Dir.pwd] : ARGV

folders.each do |folder|
Expand All @@ -17,7 +18,7 @@ folders.each do |folder|
Find.find(folder) do |path|
if File.directory?(path) && File.exists?(File.join(path, 'Gemfile.lock'))
matrix.add_project(Hellgrid::Project.new(folder, path))
Find.prune
Find.prune unless recursive_search
end
end

Expand Down
18 changes: 18 additions & 0 deletions spec/hellgrid_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,22 @@
expect(`cd #{PROJECT_ROOT}/spec/tmp && #{PROJECT_ROOT}/bin/hellgrid`).to eq(expected_result)
end
end

context 'when passing -r' do
it 'searches recursively within folders if you flag it to' do
Bundler.with_clean_env do
expect(`cd #{PROJECT_ROOT} && #{PROJECT_ROOT}/bin/hellgrid -r`).to(
include(
'hellgrid',
'spec/tmp/bar',
'spec/tmp/in/foo',
'rspec',
'3.4.0',
'2.0.0',
'3.0.0'
)
)
end
end
end
end

0 comments on commit 7c253d2

Please sign in to comment.