diff options
author | Homu <homu@barosl.com> | 2016-07-20 08:57:15 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-07-20 08:57:15 +0900 |
commit | eef043a655039a91e51004cb28d321999a8ccad7 (patch) | |
tree | 5780015f63f978a3f5852fd3305f3ff1129e3d76 | |
parent | 5515464bfc38dda105496c4db3dc21cd223cc33e (diff) | |
parent | 183b9f74f3f9767968cdc1eb2b99fd5c8fb0db78 (diff) | |
download | bundler-eef043a655039a91e51004cb28d321999a8ccad7.tar.gz |
Auto merge of #4740 - bundler:seg-print-command, r=indirect
[CLI] Print running command
This also has the nice side-effect of printing the bundler version ;)
-rw-r--r-- | lib/bundler/cli.rb | 15 | ||||
-rw-r--r-- | spec/bundler/cli_spec.rb | 7 | ||||
-rw-r--r-- | spec/other/trampoline_spec.rb | 7 |
3 files changed, 29 insertions, 0 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index ed81ffbf35..fce7380bdc 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -16,6 +16,10 @@ module Bundler Bundler::SharedHelpers.print_major_deprecations! end + def self.dispatch(*) + super {|i| i.send(:print_command) } + end + def initialize(*args) super Bundler.reset! @@ -517,5 +521,16 @@ module Bundler Bundler.reset! end end + + def print_command + return unless ENV["BUNDLE_POSTIT_TRAMPOLINING_VERSION"] || Bundler.ui.debug? + _, _, config = @_initializer + current_command = config[:current_command].name + return if %w(exec version check platform show help).include?(current_command) + command = ["bundle", current_command] + args + command << Thor::Options.to_switches(options) + command.reject!(&:empty?) + Bundler.ui.info "Running `#{command * " "}` with bundler #{Bundler::VERSION}" + end end end diff --git a/spec/bundler/cli_spec.rb b/spec/bundler/cli_spec.rb index 3fe4938f97..2237ee9731 100644 --- a/spec/bundler/cli_spec.rb +++ b/spec/bundler/cli_spec.rb @@ -54,6 +54,13 @@ describe "bundle executable" do expect(out).not_to include("RUBYGEMS_GEMDEPS") end end + + context "with --verbose" do + it "prints the running command" do + bundle! "config", :verbose => true + expect(out).to start_with("Running `bundle config --verbose` with bundler #{Bundler::VERSION}") + end + end end describe "bundler executable" do diff --git a/spec/other/trampoline_spec.rb b/spec/other/trampoline_spec.rb index 2be0c9c3e9..a498e1219e 100644 --- a/spec/other/trampoline_spec.rb +++ b/spec/other/trampoline_spec.rb @@ -150,4 +150,11 @@ You're running Bundler #{Bundler::VERSION} but this project uses #{ENV["BUNDLER_ WARN end end + + context "with --verbose" do + it "prints the running command" do + bundle! "config", :verbose => true, :env => { "BUNDLE_POSTIT_TRAMPOLINING_VERSION" => Bundler::VERSION } + expect(out).to start_with("Running `bundle config --verbose` with bundler #{Bundler::VERSION}") + end + end end |