summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBoggs <hello.boggs@gmail.com>2016-05-25 05:41:17 +0800
committerBoggs <hello.boggs@gmail.com>2016-05-25 05:41:17 +0800
commit3f8b9381b8eb47aa2ce988a9911db7d901626db6 (patch)
tree43bc5f409d29c88b4e22de72d1672bc5578ea6d0
parentdbad52b5b477936b25c2c5605247a9e70a0796cb (diff)
downloadbundler-3f8b9381b8eb47aa2ce988a9911db7d901626db6.tar.gz
Add standalone flag to binstubs, fix #4594
-rw-r--r--lib/bundler/cli.rb2
-rw-r--r--lib/bundler/cli/binstubs.rb2
-rw-r--r--spec/commands/binstubs_spec.rb15
3 files changed, 19 insertions, 0 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb
index f2af5d71f7..30fd33b755 100644
--- a/lib/bundler/cli.rb
+++ b/lib/bundler/cli.rb
@@ -229,6 +229,8 @@ module Bundler
"Overwrite existing binstubs if they exist"
method_option "path", :type => :string, :lazy_default => "bin", :banner =>
"Binstub destination directory (default bin)"
+ method_option "standalone", :type => :array, :lazy_default => [], :banner =>
+ "Make gem/s work without the Bundler runtime"
def binstubs(*gems)
require "bundler/cli/binstubs"
Binstubs.new(options, gems).run
diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb
index 8452ca3bfe..e8982e90b4 100644
--- a/lib/bundler/cli/binstubs.rb
+++ b/lib/bundler/cli/binstubs.rb
@@ -29,6 +29,8 @@ module Bundler
if spec.name == "bundler"
Bundler.ui.warn "Sorry, Bundler can only be run via Rubygems."
+ elsif options[:standalone]
+ installer.generate_standalone_bundler_executable_stubs(spec)
else
installer.generate_bundler_executable_stubs(spec, :force => options[:force], :binstubs_cmd => true)
end
diff --git a/spec/commands/binstubs_spec.rb b/spec/commands/binstubs_spec.rb
index ee319e016c..1d7deac6fd 100644
--- a/spec/commands/binstubs_spec.rb
+++ b/spec/commands/binstubs_spec.rb
@@ -145,6 +145,21 @@ describe "bundle binstubs <gem>" do
end
end
+ context "--standalone" do
+ it "includes the standalone path" do
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle "install --standalone"
+ bundle "binstubs rack --standalone"
+
+ standalone_line = File.read(bundled_app("bin/rackup")).each_line.find {|line| line.include? "$:.unshift" }.strip
+ expect(standalone_line).to eq "$:.unshift File.expand_path '../../bundle', __FILE__"
+ end
+ end
+
context "when the bin already exists" do
it "doesn't overwrite and warns" do
FileUtils.mkdir_p(bundled_app("bin"))