Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Auto merge of #5302 - bundler:seg-open-exit, r=indirect
Browse files Browse the repository at this point in the history
[CLI::Open] Support exiting when selecting gem

Closes #5301

(cherry picked from commit 8449427)
  • Loading branch information
bundlerbot authored and segiddins committed Jan 11, 2017
1 parent e9dca8b commit 9100676
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion lib/bundler/cli/open.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ def initialize(options, name)
def run
editor = [ENV["BUNDLER_EDITOR"], ENV["VISUAL"], ENV["EDITOR"]].find {|e| !e.nil? && !e.empty? }
return Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR") unless editor
path = Bundler::CLI::Common.select_spec(name, :regex_match).full_gem_path
return unless spec = Bundler::CLI::Common.select_spec(name, :regex_match)
path = spec.full_gem_path
Dir.chdir(path) do
command = Shellwords.split(editor) + [path]
Bundler.with_clean_env do
Expand Down
7 changes: 7 additions & 0 deletions spec/commands/open_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,13 @@
expect(out).to match(/bundler_editor #{default_bundle_path('gems', 'activerecord-2.3.2')}\z/)
end

it "allows selecting exit from many match gems" do
env = { "EDITOR" => "echo editor", "VISUAL" => "echo visual", "BUNDLER_EDITOR" => "echo bundler_editor" }
bundle! "open active", :env => env do |input, _, _|
input.puts "0"
end
end

it "performs an automatic bundle install" do
gemfile <<-G
source "file://#{gem_repo1}"
Expand Down

0 comments on commit 9100676

Please sign in to comment.