Default task for namespace in Rake

前端 未结 8 1521
醉酒成梦
醉酒成梦 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:51

    Combining Szymon Lipiński's and Shyam Habarakada's answers, here is what I think is the most idiomatic and consise answer:

    namespace :my_tasks do
      task :foo do
        do_something
      end
    
      task :bar do
        do_something_else
      end
    
    end
    
    task :my_tasks => ["my_tasks:foo", "my_tasks:bar"]
    

    allows you to do rake my_tasks while avoiding cumbersome invocation of the subtasks.

提交回复
热议问题