diff options
Diffstat (limited to 'lib/bundler/plugin.rb')
-rw-r--r-- | lib/bundler/plugin.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index f4dd435df4..2025e09b3d 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -47,6 +47,32 @@ module Bundler Bundler.ui.error "Failed to install plugin #{name}: #{e.message}\n #{e.backtrace.join("\n ")}" end + # Uninstalls plugins by the given names + # + # @param [Array<String>] names the names of plugins to be uninstalled + def uninstall(names, options) + if names.empty? && !options[:all] + Bundler.ui.error "No plugins to uninstall. Specify at least 1 plugin to uninstall.\n"\ + "Use --all option to uninstall all the installed plugins." + return + end + + names = index.installed_plugins if options[:all] + if names.any? + names.each do |name| + if index.installed?(name) + Bundler.rm_rf(index.plugin_path(name)) + index.unregister_plugin(name) + Bundler.ui.info "Uninstalled plugin #{name}" + else + Bundler.ui.error "Plugin #{name} is not installed \n" + end + end + else + Bundler.ui.info "No plugins installed" + end + end + # List installed plugins and commands # def list |