1
0
Fork 0
mirror of https://github.com/capistrano/capistrano synced 2023-03-27 23:21:18 -04:00

Merge pull request #1397 from Futurelearn/master

Bind post_task lazily in TaskEnhancements#after.
This commit is contained in:
Lee Hambley 2015-03-24 09:23:52 +01:00
commit 07ceeececb
3 changed files with 14 additions and 2 deletions

View file

@ -11,6 +11,7 @@ https://github.com/capistrano/capistrano/compare/v3.4.0...HEAD
* Minor changes * Minor changes
* Fix filtering behaviour when using literal hostnames in on() block (@townsen) * Fix filtering behaviour when using literal hostnames in on() block (@townsen)
* Added options to set username and password when using Subversion as SCM (@dsthode) * Added options to set username and password when using Subversion as SCM (@dsthode)
* Allow after() to refer to tasks that have not been loaded yet (@jcoglan)
## `3.4.0` ## `3.4.0`

View file

@ -9,9 +9,8 @@ module Capistrano
def after(task, post_task, *args, &block) def after(task, post_task, *args, &block)
Rake::Task.define_task(post_task, *args, &block) if block_given? Rake::Task.define_task(post_task, *args, &block) if block_given?
post_task = Rake::Task[post_task]
Rake::Task[task].enhance do Rake::Task[task].enhance do
post_task.invoke Rake::Task[post_task].invoke
end end
end end

View file

@ -54,6 +54,18 @@ module Capistrano
expect(order).to eq(['before_task', 'task', 'after_task']) expect(order).to eq(['before_task', 'task', 'after_task'])
end end
it 'invokes in proper order when referring to as-yet undefined tasks' do
task_enhancements.after('task', 'not_loaded_task')
Rake::Task.define_task('not_loaded_task') do
order.push 'not_loaded_task'
end
Rake::Task['task'].invoke order
expect(order).to eq(['task', 'not_loaded_task'])
end
it 'invokes in proper order and with arguments and block' do it 'invokes in proper order and with arguments and block' do
task_enhancements.after('task', 'after_task_custom', :order) do |t, args| task_enhancements.after('task', 'after_task_custom', :order) do |t, args|
order.push 'after_task' order.push 'after_task'