Only prepend/append once for hooks
This commit is contained in:
parent
c6a2d01cdf
commit
e5539eb769
|
@ -133,9 +133,22 @@ module Vagrant
|
||||||
if env[:action_hooks]
|
if env[:action_hooks]
|
||||||
builder = self.dup
|
builder = self.dup
|
||||||
|
|
||||||
|
# These are the options to pass into hook application.
|
||||||
|
options = {}
|
||||||
|
|
||||||
|
# If we already ran through once and did append/prepends,
|
||||||
|
# then don't do it again.
|
||||||
|
if env[:action_hooks_already_ran]
|
||||||
|
options[:no_prepend_or_append] = true
|
||||||
|
end
|
||||||
|
|
||||||
|
# Specify that we already ran, so in the future we don't repeat
|
||||||
|
# the prepend/append hooks.
|
||||||
|
env[:action_hooks_already_ran] = true
|
||||||
|
|
||||||
# Apply all the hooks to the new builder instance
|
# Apply all the hooks to the new builder instance
|
||||||
env[:action_hooks].each do |hook|
|
env[:action_hooks].each do |hook|
|
||||||
hook.apply(builder)
|
hook.apply(builder, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
# The stack is now the result of the new builder
|
# The stack is now the result of the new builder
|
||||||
|
|
|
@ -191,6 +191,16 @@ describe Vagrant::Action::Builder do
|
||||||
subject.call(data)
|
subject.call(data)
|
||||||
|
|
||||||
data[:data].should == [1, 2]
|
data[:data].should == [1, 2]
|
||||||
|
data[:action_hooks_already_ran].should == true
|
||||||
|
end
|
||||||
|
|
||||||
|
it "applies without prepend/append if it has already" do
|
||||||
|
hook = double("hook")
|
||||||
|
hook.should_receive(:apply).with(anything, { :no_prepend_or_append => true }).once
|
||||||
|
|
||||||
|
data[:action_hooks] = [hook]
|
||||||
|
data[:action_hooks_already_ran] = true
|
||||||
|
subject.call(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue