diff options
Diffstat (limited to 'lib/chef/knife')
-rw-r--r-- | lib/chef/knife/list.rb | 17 | ||||
-rw-r--r-- | lib/chef/knife/show.rb | 5 |
2 files changed, 11 insertions, 11 deletions
diff --git a/lib/chef/knife/list.rb b/lib/chef/knife/list.rb index 4338e195bd..137d61f3a5 100644 --- a/lib/chef/knife/list.rb +++ b/lib/chef/knife/list.rb @@ -43,21 +43,23 @@ class Chef def run patterns = name_args.length == 0 ? [""] : name_args - # Get the matches (recursively) - all_results = parallelize(pattern_args_from(patterns), :flatten => true) do |pattern| - pattern_results = Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern) + # Get the top-level matches + args = pattern_args_from(patterns) + all_results = parallelize(pattern_args_from(patterns)) do |pattern| + pattern_results = Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern).to_a if pattern_results.first && !pattern_results.first.exists? && pattern.exact_path ui.error "#{format_path(pattern_results.first)}: No such file or directory" self.exit_code = 1 end pattern_results - end + end.flatten(1).to_a # Process directories if !config[:bare_directories] - dir_results = parallelize(all_results.select { |result| result.dir? }, :flatten => true) do |result| + dir_results = parallelize(all_results.select { |result| result.dir? }) do |result| add_dir_result(result) - end.to_a + end.flatten(1) + else dir_results = [] end @@ -109,7 +111,7 @@ class Chef result = [ [ result, children ] ] if config[:recursive] child_dirs = children.select { |child| child.dir? } - result += parallelize(child_dirs, :flatten => true) { |child| add_dir_result(child) }.to_a + result += parallelize(child_dirs) { |child| add_dir_result(child) }.flatten(1).to_a end result end @@ -152,4 +154,3 @@ class Chef end end end - diff --git a/lib/chef/knife/show.rb b/lib/chef/knife/show.rb index acf1996e96..4684a6ac7e 100644 --- a/lib/chef/knife/show.rb +++ b/lib/chef/knife/show.rb @@ -20,7 +20,7 @@ class Chef def run # Get the matches (recursively) error = false - entry_values = parallelize(pattern_args, :flatten => true) do |pattern| + entry_values = parallelize(pattern_args) do |pattern| parallelize(Chef::ChefFS::FileSystem.list(config[:local] ? local_fs : chef_fs, pattern)) do |entry| if entry.dir? ui.error "#{format_path(entry)}: is a directory" if pattern.exact_path @@ -40,7 +40,7 @@ class Chef end end end - end + end.flatten(1) entry_values.each do |entry, value| if entry output "#{format_path(entry)}:" @@ -54,4 +54,3 @@ class Chef end end end - |