diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2017-06-20 13:15:36 -0500 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2017-07-03 15:48:24 +0200 |
commit | 5617bfb82ccfd2b77af901473cecd32fce7cc54c (patch) | |
tree | 2b159a1568713769ba62fd43a610667e584e92b6 | |
parent | eafe977fe6648447cb324321064ed55111046d9e (diff) | |
download | bundler-seg-new-cache-is-package.tar.gz |
Use the Package command for `bundle cache` on Bundler 2seg-new-cache-is-package
-rw-r--r-- | lib/bundler/cli.rb | 20 | ||||
-rw-r--r-- | lib/bundler/feature_flag.rb | 1 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 1 | ||||
-rw-r--r-- | spec/other/cli_dispatch_spec.rb | 9 | ||||
-rw-r--r-- | spec/quality_spec.rb | 1 |
5 files changed, 24 insertions, 8 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index b4437c9aec..1f01999ead 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -324,16 +324,20 @@ module Bundler Outdated.new(options, gems).run end - desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true - method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)." - method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one" - method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache." - def cache - require "bundler/cli/cache" - Cache.new(options).run + if Bundler.feature_flag.cache_command_is_package? + map %w[cache] => :package + else + desc "cache [OPTIONS]", "Cache all the gems to vendor/cache", :hide => true + method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)." + method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one" + method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache." + def cache + require "bundler/cli/cache" + Cache.new(options).run + end end - desc "package [OPTIONS]", "Locks and then caches all of the gems into vendor/cache" + desc "#{Bundler.feature_flag.cache_command_is_package? ? :cache : :package} [OPTIONS]", "Locks and then caches all of the gems into vendor/cache" method_option "all", :type => :boolean, :banner => "Include all sources (including path and git)." method_option "all-platforms", :type => :boolean, :banner => "Include gems for all platforms present in the lockfile, not only the current one" method_option "cache-path", :type => :string, :banner => diff --git a/lib/bundler/feature_flag.rb b/lib/bundler/feature_flag.rb index 318ad5dee7..180c442ffb 100644 --- a/lib/bundler/feature_flag.rb +++ b/lib/bundler/feature_flag.rb @@ -28,6 +28,7 @@ module Bundler settings_flag(:allow_bundler_dependency_conflicts) { bundler_2_mode? } settings_flag(:allow_offline_install) { bundler_2_mode? } + settings_flag(:cache_command_is_package) { bundler_2_mode? } settings_flag(:console_command) { !bundler_2_mode? } settings_flag(:disable_multisource) { bundler_2_mode? } settings_flag(:error_on_stderr) { bundler_2_mode? } diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index 8521f8658d..8e9848d57a 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -12,6 +12,7 @@ module Bundler auto_install cache_all cache_all_platforms + cache_command_is_package console_command disable_checksum_validation disable_exec_load diff --git a/spec/other/cli_dispatch_spec.rb b/spec/other/cli_dispatch_spec.rb index 05d313ef2b..a9d0bf7462 100644 --- a/spec/other/cli_dispatch_spec.rb +++ b/spec/other/cli_dispatch_spec.rb @@ -17,4 +17,13 @@ RSpec.describe "bundle command names" do bundle "in" expect(last_command.bundler_err).to eq("Ambiguous command in matches [info, init, inject, install]") end + + context "when cache_command_is_package is set" do + before { bundle! "config cache_command_is_package true" } + + it "dispatches `bundle cache` to the package command" do + bundle "cache --verbose" + expect(last_command.stdout).to start_with "Running `bundle package --no-color --verbose`" + end + end end diff --git a/spec/quality_spec.rb b/spec/quality_spec.rb index 694bc7efc3..ced7f0d2e4 100644 --- a/spec/quality_spec.rb +++ b/spec/quality_spec.rb @@ -169,6 +169,7 @@ RSpec.describe "The library itself" do it "documents all used settings" do exemptions = %w[ + cache_command_is_package console_command default_cli_command gem.coc |