Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to pass parameters to task prerequisite #292

Open
novill opened this issue Nov 21, 2018 · 1 comment
Open

Unable to pass parameters to task prerequisite #292

novill opened this issue Nov 21, 2018 · 1 comment

Comments

@novill
Copy link

novill commented Nov 21, 2018

I need before and after hooks for all rake tasks.

task :my_before_hook, [:name] => :environment do |_t, args|
  puts "Rake task #{args[:name]} started"
end

task :my_after_hook, [:name] => :environment do |_t, args|
  puts "Rake task #{args[:name]} finished"
end

task :my_test_task  => :environment do
  puts '--------- This is test task'
end

Rake.application.tasks.each do |tsk|
  next if [Rake::Task['my_before_hook'],
           Rake::Task['my_after_hook']].include?(tsk)

  tsk.enhance ['my_before_hook'] # I can't send any params with such code

  tsk.enhance do
    Rake::Task['my_after_hook'].invoke(tsk.name)
  end
end

Is there any way to send params to prerequisite?

@kenzan100
Copy link

Hi! Has anybody found a way to do this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants