diff options
author | Dennis Suratna <dennis.suratna@gmail.com> | 2017-03-06 15:58:35 -0800 |
---|---|---|
committer | Dennis Suratna <dennis.suratna@gmail.com> | 2017-04-11 18:33:26 +0700 |
commit | 37c4528239089ef123cd20b9e2c2975d5cce9074 (patch) | |
tree | 121860d81d1860fe6ac22941f6f357ab327d1545 | |
parent | 32fb8327328789bdc911dccda4a59e99956c558c (diff) | |
download | bundler-37c4528239089ef123cd20b9e2c2975d5cce9074.tar.gz |
Initial implementation of 'bundle pristine'
-rw-r--r-- | lib/bundler/cli.rb | 6 | ||||
-rw-r--r-- | lib/bundler/cli/pristine.rb | 39 |
2 files changed, 45 insertions, 0 deletions
diff --git a/lib/bundler/cli.rb b/lib/bundler/cli.rb index 61c5427c90..5eeb1f8018 100644 --- a/lib/bundler/cli.rb +++ b/lib/bundler/cli.rb @@ -540,6 +540,12 @@ module Bundler Issue.new.run end + desc "pristine", "Restores installed gems to pristine condition from files located in the gem cache. Gem installed from a git repository will be issued `git checkout --force`." + def pristine + require "bundler/cli/pristine" + Pristine.new.run + end + if Bundler.feature_flag.plugins? require "bundler/cli/plugin" desc "plugin SUBCOMMAND ...ARGS", "manage the bundler plugins" diff --git a/lib/bundler/cli/pristine.rb b/lib/bundler/cli/pristine.rb new file mode 100644 index 0000000000..539e38f2ff --- /dev/null +++ b/lib/bundler/cli/pristine.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true +require "bundler/cli/common" + +module Bundler + class CLI::Pristine + def run + + ::Bundler.load.specs.each do |spec| + + gem_name = "#{spec.name} (#{spec.version}#{spec.git_version})" + + if spec.source.is_a?(Source::Path) + ::Bundler.ui.warn("Cannot pristine #{gem_name} Gem is sourced from path.") + next + end + + if spec.source.is_a?(Source::Rubygems) + cached_gem = spec.cache_file + unless File.exists?(cached_gem) + ::Bundler.ui.error("Failed to pristine #{gem_name}. Cached gem #{cached_gem} does not exist.") + next + end + + installer = Gem::Installer.at(cached_gem, + :wrappers => true, + :force => true, + :install_dir => spec.base_dir, + :build_args => spec.build_args) + installer.install + + elsif spec.source.is_a?(Source::Git) + + end + + + end + end + end +end |