Reputation: 7490
How can I run all rake tasks?
task :a do
# stuff
end
task :b do
# stuff
end
task :c do
# stuff
end
task :all do
# Run all other tasks?
end
I know I can just do
task :all => [:a, :b, :c] do
end
but if I add new task, I also need to add it to :all
dependencies. I would
like to avoid the need to do it manually since it seems like easy thing to forget.
Upvotes: 2
Views: 1541
Reputation: 14047
Here's one way:
namespace :hot_tasks do |hot_tasks_namespace|
task :task1 do
puts 1
end
task :task2 do
puts 2
end
task :all do
hot_tasks_namespace.tasks.each do |task|
Rake::Task[task].invoke
end
end
end
running it:
# bundle exec rake hot_tasks:all
1
2
More (not necessarily better) ideas at this question, especially if you're in a rails app.
Upvotes: 2