diff options
Diffstat (limited to 'lib/bundler/plugin.rb')
-rw-r--r-- | lib/bundler/plugin.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/bundler/plugin.rb b/lib/bundler/plugin.rb index edd1900135..fbbb5950f7 100644 --- a/lib/bundler/plugin.rb +++ b/lib/bundler/plugin.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "set" + require_relative "plugin/api" module Bundler @@ -25,7 +27,7 @@ module Bundler @sources = {} @commands = {} @hooks_by_event = Hash.new {|h, k| h[k] = [] } - @loaded_plugin_names = [] + @loaded_plugin_names = Set.new end reset! @@ -228,7 +230,7 @@ module Bundler plugins = index.hook_plugins(event) return unless plugins.any? - (plugins - @loaded_plugin_names).each {|name| load_plugin(name) } + plugins.each {|name| load_plugin(name) } @hooks_by_event[event].each {|blk| blk.call(*args, &arg_blk) } end @@ -240,6 +242,11 @@ module Bundler Index.new.installed?(plugin) end + # @return [true, false] whether the plugin is loaded + def loaded?(plugin) + @loaded_plugin_names.include?(plugin) + end + # Post installation processing and registering with index # # @param [Array<String>] plugins list to be installed @@ -330,6 +337,7 @@ module Bundler # @param [String] name of the plugin def load_plugin(name) return unless name && !name.empty? + return if loaded?(name) # Need to ensure before this that plugin root where the rest of gems # are installed to be on load path to support plugin deps. Currently not |