Setup hooks in the runner

This commit is contained in:
Mitchell Hashimoto 2013-02-06 15:37:12 -08:00
parent aa7193471f
commit b20dcc9eb8
2 changed files with 24 additions and 0 deletions

View File

@ -27,6 +27,19 @@ module Vagrant
environment.merge!(@lazy_globals.call) if @lazy_globals
environment.merge!(options || {})
# Setup the action hooks
hooks = Vagrant.plugin("2").manager.action_hooks
if !hooks.empty?
@logger.info("Preparing hooks for middleware sequence...")
env[:action_hooks] = hooks.map do |hook_proc|
Hook.new.tap do |h|
hook_proc.call(h)
end
end
@logger.info("#{env[:action_hooks].length} hooks defined.")
end
# Run the action chain in a busy block, marking the environment as
# interrupted if a SIGINT occurs, and exiting cleanly once the
# chain has been run.

View File

@ -14,6 +14,17 @@ module Vagrant
@registered = []
end
# This returns all the action hooks.
#
# @return [Array]
def action_hooks
[].tap do |result|
@registered.each do |plugin|
result += plugin.components.action_hooks
end
end
end
# This returns all the registered commands.
#
# @return [Hash]