Permalink
Browse files

Make generating bin stubs an option

  • Loading branch information...
1 parent 33121dc commit 25ab2dc405bce75fd9b1faff2b37fa79b5c2235d Carl Lerche committed Jul 9, 2010
Showing with 48 additions and 6 deletions.
  1. +2 −1 lib/bundler.rb
  2. +3 −0 lib/bundler/cli.rb
  3. +1 −1 lib/bundler/installer.rb
  4. +42 −4 spec/runtime/executable_spec.rb
View
@@ -82,7 +82,8 @@ def bundle_path
def bin_path
@bin_path ||= begin
- path = settings[:bin] || "#{root}/bin"
+ path = settings[:bin] || "bin"
+ path = Pathname.new(path).expand_path(root)
FileUtils.mkdir_p(path)
Pathname.new(path).expand_path
end
View
@@ -96,6 +96,8 @@ def check
"Only output warnings and errors."
method_option "local", :type => :boolean, :banner =>
"Do not attempt to fetch gems remotely and use the gem cache instead"
+ method_option "binstubs", :type => :boolean, :banner =>
+ "Generate bin stubs for bundled gems to ./bin"
def install(path = nil)
opts = options.dup
opts[:without] ||= []
@@ -104,6 +106,7 @@ def install(path = nil)
# Can't use Bundler.settings for this because settings needs gemfile.dirname
ENV['BUNDLE_GEMFILE'] = opts[:gemfile] if opts[:gemfile]
Bundler.settings[:path] = path if path
+ Bundler.settings[:bin] = 'bin' if opts[:binstubs]
Bundler.settings[:disable_shared_gems] = '1' if options["disable-shared-gems"] || path
Bundler.settings.without = opts[:without]
Bundler.ui.be_quiet! if opts[:quiet]
View
@@ -37,7 +37,7 @@ def run(options)
spec.source.install(spec)
Bundler.ui.info ""
- generate_bundler_executable_stubs(spec)
+ generate_bundler_executable_stubs(spec) if Bundler.settings[:bin]
FileUtils.rm_rf(Bundler.tmp)
end
@@ -2,11 +2,13 @@
describe "Running bin/* commands" do
it "runs the bundled command when in the bundle" do
- install_gemfile <<-G
+ gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
+ bundle "install --binstubs"
+
build_gem "rack", "2.0", :to_system => true do |s|
s.executables = "rackup"
end
@@ -16,11 +18,13 @@
end
it "runs the bundled command when out of the bundle" do
- install_gemfile <<-G
+ gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
+ bundle "install --binstubs"
+
build_gem "rack", "2.0", :to_system => true do |s|
s.executables = "rackup"
end
@@ -36,10 +40,12 @@
s.executables = 'rackup'
end
- install_gemfile <<-G
+ gemfile <<-G
gem "rack", :path => "#{lib_path('rack')}"
G
+ bundle "install --binstubs"
+
build_gem 'rack', '2.0', :to_system => true do |s|
s.executables = 'rackup'
end
@@ -53,11 +59,43 @@
s.executables = "bundle"
end
- install_gemfile <<-G
+ gemfile <<-G
source "file://#{gem_repo1}"
gem "bundler"
G
+ bundle "install --binstubs"
+
bundled_app("bin/bundle").should_not exist
end
+
+ it "does not generate bin stubs if the option was not specified" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "rack"
+ G
+
+ bundle "install"
+
+ bundled_app("bin/rackup").should_not exist
+ end
+
+ it "remembers that the option was specified" do
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "activesupport"
+ G
+
+ bundle "install --binstubs"
+
+ gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "activesupport"
+ gem "rack"
+ G
+
+ bundle "install"
+
+ bundled_app("bin/rackup").should exist
+ end
end

0 comments on commit 25ab2dc

Please sign in to comment.