26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/bundler/download.rb', line 26
def exec(command, args)
begin
subcommand = extract_subcommand(args) || 'start'
return puts("Invalid subcommand: #{subcommand} \nValid `bundle download` subcommands are: #{Bundler::Downloadfile::SUBCOMMANDS.join(' / ')}") unless Bundler::Downloadfile::SUBCOMMANDS.include?(subcommand)
downloadfiles = Dir.glob(File.join(Gem.dir, 'gems', '**', 'Downloadfile')).to_a
loaded_gems = Gem.loaded_specs.keys
downloadfiles = downloadfiles.select {|df| loaded_gems.detect {|gem| File.basename(File.dirname(df)).include?(gem)} }
downloadfiles << 'Downloadfile' if File.exist?('Downloadfile')
puts 'No gems were found with Downloadfile.' if downloadfiles.empty?
help_requested = subcommand == 'help' || subcommand == 'usage'
help_shown = false
downloadfiles.each do |downloadfile|
bundler_downloadfile = Bundler::Downloadfile.new(
downloadfile,
gem_path: File.dirname(downloadfile),
keep_existing: args.include?('--keep-existing'),
all_operating_systems: args.include?('--all-operating-systems'),
)
if !help_requested || !help_shown
puts "== bundler-download - Bundler Plugin - v#{File.read(File.expand_path('../../../VERSION', __FILE__)).strip} =="
puts
bundler_downloadfile.send(subcommand)
end
help_shown = true if help_requested
end
true
rescue => e
puts e.full_message
false
end
end
|