Default task for namespace in Rake

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

    Based on Rocky's solution Default task for namespace in Rake

    And this dexter's answer Is there a way to know the current rake task?

    namespace :root do
      namespace :foo do
      end
    
      namespace :target do
        task :all do |task_all|
          Rake.application.in_namespace(task_all.scope.path) do |ns|
            ns.tasks.each { |task| task.invoke unless task.name == task_all.name } 
          end
        end
    
        task :one do
        end
    
        task :another do
        end
      end
    end
    

提交回复
热议问题