Merge pull request #2437 from fgrehm/plugins-loaded-hook

core: plugins loaded hook with no vagrantfiles
This commit is contained in:
Mitchell Hashimoto 2013-11-23 16:38:45 -08:00
commit 1ea39ab605
2 changed files with 15 additions and 2 deletions

View File

@ -131,6 +131,10 @@ module Vagrant
# Load the plugins
load_plugins
# Call the hooks that does not require configurations to be loaded
# by using a "clean" action runner
hook(:environment_plugins_loaded, Action::Runner.new)
# Call the environment load hooks
hook(:environment_load)
end
@ -268,10 +272,11 @@ module Vagrant
# against the given name will be run in the context of this environment.
#
# @param [Symbol] name Name of the hook.
def hook(name)
# @param [Action::Runner] action_runner A custom action runner for running hooks.
def hook(name, runner = action_runner)
@logger.info("Running hook: #{name}")
callable = Action::Builder.new
action_runner.run(
runner.run(
callable,
:action_name => name,
:env => self)

View File

@ -308,6 +308,14 @@ describe Vagrant::Environment do
instance.hook(:bar).should == :foo
end
it "should allow passing in a custom action runner" do
instance.action_runner.should_not_receive(:run)
other_runner = mock
other_runner.should_receive(:run).with(:bar).and_return(:foo)
instance.hook(:bar, other_runner).should == :foo
end
end
describe "primary machine name" do