Skip to content
This repository was archived by the owner on Apr 14, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion lib/bundler/plugin/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,10 @@ def register_plugin(name, path, load_paths, commands, sources, hooks)
raise SourceConflict.new(name, common) unless common.empty?
sources.each {|k| @sources[k] = name }

hooks.each {|e| (@hooks[e] ||= []) << name }
hooks.each do |event|
event_hooks = (@hooks[event] ||= []) << name
event_hooks.uniq!
end

@plugin_paths[name] = path
@load_paths[name] = load_paths
Expand Down
11 changes: 11 additions & 0 deletions spec/bundler/plugin/index_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,17 @@
expect(new_index.hook_plugins("after-bar")).to eq([plugin_name])
end

it "only registers a gem once for an event" do
path = lib_path(plugin_name)
index.register_plugin(plugin_name,
path.to_s,
[path.join("lib").to_s],
commands,
sources,
hooks + hooks)
expect(index.hook_plugins("after-bar")).to eq([plugin_name])
end

context "that are not registered", :focused do
let(:file) { double("index-file") }

Expand Down