summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjules2689 <julian@jnadeau.ca>2018-05-22 22:57:57 -0400
committerjules2689 <julian@jnadeau.ca>2018-06-12 13:56:29 -0400
commit4b081829e0797a3c46f9083be7d369e0be2244ef (patch)
tree074197ed90c7d7921da61545178e6f32f3b93ae8
parent31b53cf987f5e737e1cddc70881d55b0eec8c38f (diff)
downloadbundler-4b081829e0797a3c46f9083be7d369e0be2244ef.tar.gz
Add registered events for after-all, before, after gem install
-rw-r--r--lib/bundler/installer.rb1
-rw-r--r--lib/bundler/installer/parallel_installer.rb2
-rw-r--r--lib/bundler/plugin/events.rb24
3 files changed, 26 insertions, 1 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index b934c38b94..dd30bd5b64 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -23,6 +23,7 @@ module Bundler
installer = new(root, definition)
Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL_ALL, definition.dependencies)
installer.run(options)
+ Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL_ALL, definition.dependencies)
installer
end
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index 61ee001538..29dee3e514 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -156,6 +156,7 @@ module Bundler
end
def do_install(spec_install, worker_num)
+ Plugin.hook(Plugin::Events::GEM_BEFORE_INSTALL, spec_install)
gem_installer = Bundler::GemInstaller.new(
spec_install.spec, @installer, @standalone, worker_num, @force
)
@@ -171,6 +172,7 @@ module Bundler
spec_install.state = :failed
spec_install.error = "#{message}\n\n#{require_tree_for_spec(spec_install.spec)}"
end
+ Plugin.hook(Plugin::Events::GEM_AFTER_INSTALL, spec_install)
spec_install
end
diff --git a/lib/bundler/plugin/events.rb b/lib/bundler/plugin/events.rb
index 26bd59e5cf..bc037d1af5 100644
--- a/lib/bundler/plugin/events.rb
+++ b/lib/bundler/plugin/events.rb
@@ -31,9 +31,31 @@ module Bundler
end
# @!parse
- # # A hook called before any gems install
+ # A hook called before each individual gem is installed
+ # Includes a Bundler::ParallelInstaller::SpecInstallation.
+ # No state, error, post_install_message will be present as nothing has installed yet
+ # GEM_BEFORE_INSTALL = "before-install"
+ define :GEM_BEFORE_INSTALL, "before-install"
+
+ # @!parse
+ # A hook called after each individual gem is installed
+ # Includes a Bundler::ParallelInstaller::SpecInstallation.
+ # - If state is failed, an error will be present.
+ # - If state is success, a post_install_message may be present.
+ # GEM_AFTER_INSTALL = "after-install"
+ define :GEM_AFTER_INSTALL, "after-install"
+
+ # @!parse
+ # A hook called before any gems install
+ # Includes an Array of Bundler::Dependency objects
# GEM_BEFORE_INSTALL_ALL = "before-install-all"
define :GEM_BEFORE_INSTALL_ALL, "before-install-all"
+
+ # @!parse
+ # A hook called after any gems install
+ # Includes an Array of Bundler::Dependency objects
+ # GEM_AFTER_INSTALL_ALL = "after-install-all"
+ define :GEM_AFTER_INSTALL_ALL, "after-install-all"
end
end
end