Skip to content

Commit

Permalink
Move rescue block around the code that can raise it
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez committed Jul 26, 2021
1 parent 86d692e commit 310937a
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
8 changes: 1 addition & 7 deletions bundler/lib/bundler/cli/install.rb
Expand Up @@ -60,7 +60,7 @@ def run
installer = Installer.install(Bundler.root, definition, options)

Bundler.settings.temporary(:cache_all_platforms => options[:local] ? false : Bundler.settings[:cache_all_platforms]) do
Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
Bundler.load.cache(nil, options[:local]) if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.frozen_bundle?
end

Bundler.ui.confirm "Bundle complete! #{dependencies_count_for(definition)}, #{gems_installed_for(definition)}."
Expand All @@ -83,12 +83,6 @@ def run
end

Bundler::CLI::Common.output_fund_metadata_summary
rescue GemNotFound
if options[:local]
Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
end

raise
rescue Gem::InvalidSpecificationException
Bundler.ui.warn "You have one or more invalid gemspecs that need to be fixed."
raise
Expand Down
17 changes: 15 additions & 2 deletions bundler/lib/bundler/runtime.rb
Expand Up @@ -104,15 +104,28 @@ def lock(opts = {})

alias_method :gems, :specs

def cache(custom_path = nil)
def cache(custom_path = nil, local = false)
cache_path = Bundler.app_cache(custom_path)
SharedHelpers.filesystem_access(cache_path) do |p|
FileUtils.mkdir_p(p)
end unless File.exist?(cache_path)

Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"

specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
specs_to_cache = if Bundler.settings[:cache_all_platforms]
@definition.resolve.materialized_for_all_platforms
else
begin
specs
rescue GemNotFound
if local
Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
end

raise
end
end

specs_to_cache.each do |spec|
next if spec.name == "bundler"
next if spec.source.is_a?(Source::Gemspec)
Expand Down

0 comments on commit 310937a

Please sign in to comment.