Fix some issues to get hooks working

This commit is contained in:
Mitchell Hashimoto 2013-02-06 15:42:48 -08:00
parent b20dcc9eb8
commit 352fec0359
2 changed files with 9 additions and 6 deletions

View File

@ -1,5 +1,6 @@
require 'log4r' require 'log4r'
require 'vagrant/action/hook'
require 'vagrant/util/busy' require 'vagrant/util/busy'
# TODO: # TODO:
@ -31,13 +32,13 @@ module Vagrant
hooks = Vagrant.plugin("2").manager.action_hooks hooks = Vagrant.plugin("2").manager.action_hooks
if !hooks.empty? if !hooks.empty?
@logger.info("Preparing hooks for middleware sequence...") @logger.info("Preparing hooks for middleware sequence...")
env[:action_hooks] = hooks.map do |hook_proc| environment[:action_hooks] = hooks.map do |hook_proc|
Hook.new.tap do |h| Hook.new.tap do |h|
hook_proc.call(h) hook_proc.call(h)
end end
end end
@logger.info("#{env[:action_hooks].length} hooks defined.") @logger.info("#{environment[:action_hooks].length} hooks defined.")
end end
# Run the action chain in a busy block, marking the environment as # Run the action chain in a busy block, marking the environment as

View File

@ -18,11 +18,13 @@ module Vagrant
# #
# @return [Array] # @return [Array]
def action_hooks def action_hooks
[].tap do |result| result = []
@registered.each do |plugin| @registered.each do |plugin|
result += plugin.components.action_hooks result += plugin.components.action_hooks
end end
end
result
end end
# This returns all the registered commands. # This returns all the registered commands.