summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2013-01-22 00:29:12 -0800
committerAndre Arko <andre@arko.net>2013-01-22 00:29:24 -0800
commit08138dc6f2296b171b1a7cc8d9d8451e3deebade (patch)
tree6451a79a79aef6d1ce66b5bd50c45c41198a52fb
parentb240103bb705cf18e074ca8b99e1ebef07bc7394 (diff)
downloadbundler-08138dc6f2296b171b1a7cc8d9d8451e3deebade.tar.gz
silently don't overwrite on --binstubs
fixes #2253
-rw-r--r--lib/bundler/installer.rb21
-rw-r--r--spec/runtime/executable_spec.rb4
2 files changed, 12 insertions, 13 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index 6a8fbbb901..d9adf3748c 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -134,22 +134,21 @@ module Bundler
ruby_command = ruby_command = Thor::Util.ruby_command
spec.executables.each do |executable|
- write = true
- binstub_path = "#{bin_path}/#{executable}"
next if executable == "bundle"
- if File.exists?(binstub_path) && !options[:force] && options[:binstubs_cmd]
- write = false
- Bundler.ui.warn <<-MSG
- Skipping #{executable} since it already exists. Pass --force to overwrite.
- MSG
- end
- if write
- File.open binstub_path, 'w', 0755 do |f|
- f.puts ERB.new(template, nil, '-').result(binding)
+ binstub_path = "#{bin_path}/#{executable}"
+ if File.exists?(binstub_path) && !options[:force]
+ if options[:binstubs_cmd]
+ Bundler.ui.warn "Skipping #{executable} since it already exists. Pass --force to overwrite."
end
+ next
+ end
+
+ File.open(binstub_path, 'w', 0755) do |f|
+ f.puts ERB.new(template, nil, '-').result(binding)
end
end
+
end
private
diff --git a/spec/runtime/executable_spec.rb b/spec/runtime/executable_spec.rb
index 3040562e6d..dcb205899c 100644
--- a/spec/runtime/executable_spec.rb
+++ b/spec/runtime/executable_spec.rb
@@ -130,7 +130,7 @@ describe "Running bin/* commands" do
expect(bundled_app("bin/rackup")).to exist
end
- it "always reinstalls the binstub" do
+ it "doesn't overwrite on --binstub" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
@@ -144,6 +144,6 @@ describe "Running bin/* commands" do
bundle "install"
- expect(File.read(bundled_app("bin/rackup"))).not_to eq("OMG")
+ expect(bundled_app("bin/rackup").read).to eq("OMG")
end
end