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

Commit

Permalink
Merge pull request #1426 from hone/1247_bundle_force
Browse files Browse the repository at this point in the history
add --force to bundle clean
  • Loading branch information
Andre Arko committed Sep 18, 2011
2 parents 4649817 + ee73d0b commit 8497f4b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
8 changes: 5 additions & 3 deletions lib/bundler/cli.rb
Expand Up @@ -568,11 +568,13 @@ def self.source_root
end

desc "clean", "Cleans up unused gems in your bundler directory"
method_option "force", :type => :boolean, :default => false, :banner =>
"forces clean even if --path is set"
def clean
if Bundler.settings[:path] == nil
Bundler.ui.error "Can only use bundle clean when --path is set"
else
if Bundler.settings[:path] || options[:force]
Bundler.load.clean
else
Bundler.ui.error "Can only use bundle clean when --path is set or --force is set"
end
end

Expand Down
25 changes: 24 additions & 1 deletion spec/other/clean_spec.rb
Expand Up @@ -241,7 +241,7 @@ def should_not_have_gems(*gems)

bundle :clean

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

# handling bundle clean upgrade path from the pre's
Expand Down Expand Up @@ -371,4 +371,27 @@ def should_not_have_gems(*gems)
sys_exec "gem list"
out.should include("foo (1.0.1, 1.0)")
end

it "cleans system gems when --force is used" do
gemfile <<-G
source "file://#{gem_repo1}"
gem "foo"
gem "rack"
G
bundle :install

gemfile <<-G
source "file://#{gem_repo1}"
gem "rack"
G
bundle :install
bundle "clean --force"

out.should eq("Removing foo (1.0)")
sys_exec "gem list"
out.should_not include("foo (1.0)")
out.should include("rack (1.0.0)")
end
end

0 comments on commit 8497f4b

Please sign in to comment.