Skip to content

Commit

Permalink
bundle clean requires --path to be set
Browse files Browse the repository at this point in the history
  • Loading branch information
hone committed Oct 27, 2010
1 parent 3f86380 commit 2ee9389
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/bundler/cli.rb
Expand Up @@ -498,8 +498,14 @@ def self.source_root

desc "clean", "Cleans up unused gems in your bundler directory"
def clean
Bundler.load.clean.each do |gem|
Bundler.ui.info "Removing #{gem}"
clean_output = Bundler.load.clean
if clean_output.is_a?(Array)
clean_output.each do |gem|
Bundler.ui.info "Removing #{gem}"
end
else

Bundler.ui.error "Can only use bundle clean when --path is set"
end
end

Expand Down
1 change: 1 addition & 0 deletions lib/bundler/runtime.rb
Expand Up @@ -116,6 +116,7 @@ def prune_cache
end

def clean
return false if Bundler.settings[:path] == nil
gem_bins = Dir["#{Gem.dir}/bin/*"]
stale_gem_bins = gem_bins - specs.collect do |spec|
spec.executables.collect do |executable|
Expand Down
13 changes: 13 additions & 0 deletions spec/other/clean_spec.rb
Expand Up @@ -191,4 +191,17 @@

vendored_gems("bin/rackup").should exist
end

it "displays an error when used without --path" do
install_gemfile <<-G
source "file://#{gem_repo1}"
gem "rack", "1.0.0"
G

bundle :install
bundle :clean

out.should == "Can only use bundle clean when --path is set"
end
end

0 comments on commit 2ee9389

Please sign in to comment.