lib/vagrant/plugin/v2/trigger.rb in vagrant-unbundled-2.1.4.0 vs lib/vagrant/plugin/v2/trigger.rb in vagrant-unbundled-2.2.0.0

- old
+ new

@@ -122,17 +122,25 @@ if trigger.warn warn(trigger.warn) end + if trigger.abort + trigger_abort(trigger.abort) + end + if trigger.run run(trigger.run, trigger.on_error, trigger.exit_codes) end if trigger.run_remote run_remote(trigger.run_remote, trigger.on_error, trigger.exit_codes) end + + if trigger.ruby_block + execute_ruby(trigger.ruby_block) + end end end # Prints the given message at info level for a trigger # @@ -238,9 +246,24 @@ else @logger.debug("Trigger run encountered an error. Continuing on anyway...") @machine.ui.error(e.message) end end + end + + # Exits Vagrant immediately + # + # @param [Integer] code Code to exit Vagrant on + def trigger_abort(exit_code) + @machine.ui.warn(I18n.t("vagrant.trigger.abort")) + exit(exit_code) + end + + # Calls the given ruby block for execution + # + # @param [Proc] ruby_block + def execute_ruby(ruby_block) + ruby_block.call(@env, @machine) end end end end end