cross_check_for_errors(gemfile_path, original_deps, removed_deps, initial_gemfile)
private
@param [Pathname] gemfile_path The Gemfile
from which to remove
dependencies. @param [Array] original_deps Array of original dependencies. @param [Array] removed_deps Array of removed dependencies. @param [Array] initial_gemfile Contents of original
Gemfile before any operation.
Show source
def cross_check_for_errors(gemfile_path, original_deps, removed_deps, initial_gemfile)
builder = Dsl.new
builder.eval_gemfile(gemfile_path)
extra_removed_gems = original_deps - builder.dependencies
unless extra_removed_gems.empty?
SharedHelpers.write_to_gemfile(gemfile_path, initial_gemfile.join)
raise InvalidOption, "Gems could not be removed. #{extra_removed_gems.join(", ")} would also have been removed. Bundler cannot continue."
end
errored_deps = builder.dependencies.select {|d| d.gemfile == gemfile_path } & removed_deps.select {|d| d.gemfile == gemfile_path }
show_warning "#{errored_deps.map(&:name).join(", ")} could not be removed." unless errored_deps.empty?
removed_deps - errored_deps
end