From 293ad80da8939f766fe886c7653903f09b6133d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Luis=20Leal=20Cardoso=20Junior?= Date: Fri, 25 Oct 2019 16:23:12 -0300 Subject: Make bundle add caches newly added gems when needed. --- lib/bundler/cli/add.rb | 1 + spec/commands/add_spec.rb | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/lib/bundler/cli/add.rb b/lib/bundler/cli/add.rb index 7c6235f17c..07b951f1ef 100644 --- a/lib/bundler/cli/add.rb +++ b/lib/bundler/cli/add.rb @@ -21,6 +21,7 @@ module Bundler def perform_bundle_install Installer.install(Bundler.root, Bundler.definition) + Bundler.load.cache if Bundler.app_cache.exist? end def inject_dependencies diff --git a/spec/commands/add_spec.rb b/spec/commands/add_spec.rb index fdfca5d8f2..35fd43d3d2 100644 --- a/spec/commands/add_spec.rb +++ b/spec/commands/add_spec.rb @@ -239,4 +239,13 @@ RSpec.describe "bundle add" do expect(err).not_to include("You may also need to change the version requirement specified in the Gemfile if it's too restrictive") end end + + describe "when a gem is added and cache exists" do + it "caches all new dependencies added for the specified gem" do + bundle! :cache + + bundle "add 'rack' --version=1.0.0" + expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist + end + end end -- cgit v1.2.1