Default task for namespace in Rake

前端 未结 8 1538
醉酒成梦
醉酒成梦 2020-12-12 23:05

Given something like:

namespace :my_tasks do
  task :foo do
    do_something
  end

  task :bar do
    do_something_else
  end

  task :all => [:foo, :bar         


        
8条回答
  •  清歌不尽
    2020-12-12 23:57

    I suggest you to use this if you have lots of tasks in the namespace.

    task :my_tasks do
      Rake.application.in_namespace(:my_tasks){|x| x.tasks.each{|t| t.invoke}}
    end
    

    And then you can run all tasks in the namespace by:

    rake my_tasks
    

    With this, you don't need to worry to change your :all task when you add new tasks into that namespace.

提交回复
热议问题