environment_unload hook
This commit is contained in:
parent
3c343c0623
commit
46db50680b
|
@ -45,7 +45,13 @@ begin
|
|||
env.ui.warn(I18n.t("vagrant.general.not_in_installer")) if !Vagrant.in_installer?
|
||||
|
||||
# Execute the CLI interface, and exit with the proper error code
|
||||
exit(env.cli(ARGV))
|
||||
exit_status = env.cli(ARGV)
|
||||
|
||||
# Unload the environment so cleanup can be done
|
||||
env.unload
|
||||
|
||||
# Exit with the exit status from our CLI command
|
||||
exit(exit_status)
|
||||
rescue Vagrant::Errors::VagrantError => e
|
||||
logger.error("Vagrant experienced an error! Details:")
|
||||
logger.error(e.inspect)
|
||||
|
|
|
@ -379,6 +379,18 @@ module Vagrant
|
|||
nil
|
||||
end
|
||||
|
||||
# Unload the environment, running completion hooks. The environment
|
||||
# should not be used after this (but CAN be, technically). It is
|
||||
# recommended to always immediately set the variable to `nil` after
|
||||
# running this so you can't accidentally run any more methods. Example:
|
||||
#
|
||||
# env.unload
|
||||
# env = nil
|
||||
#
|
||||
def unload
|
||||
hook(:environment_unload)
|
||||
end
|
||||
|
||||
# Makes a call to the CLI with the given arguments as if they
|
||||
# came from the real command line (sometimes they do!). An example:
|
||||
#
|
||||
|
|
|
@ -300,6 +300,13 @@ VF
|
|||
end
|
||||
end
|
||||
|
||||
describe "#unload" do
|
||||
it "should run the unload hook" do
|
||||
instance.should_receive(:hook).with(:environment_unload).once
|
||||
instance.unload
|
||||
end
|
||||
end
|
||||
|
||||
describe "getting a machine" do
|
||||
# A helper to register a provider for use in tests.
|
||||
def register_provider(name, config_class=nil)
|
||||
|
|
Loading…
Reference in New Issue