Unable to pass parameters to task prerequisite
Open
Nobody has claimed this yet.
- Dominant language
- Ruby
- Stars
- 2.5k
- Forks
- 650
- Avg merge
- 6m
- Merged PRs (30d)
- 3
Description
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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Rake::Task#enhance and Rake::Task#invoke entry points used in the example. Trace how the prerequisite is invoked and determine whether parameters can be passed through that path. Done means establishing the supported behavior or documenting the required change, with coverage for the hook example if tests are added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- ruby
- Domain
- build-system, cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100