How to invoke rake with non-rake parameters

你说的曾经没有我的故事 提交于 2019-12-07 07:14:54

问题


I have a rake task that creates diagrams:

task :diagram do
  `rake erd filetype=dot disconnected=true`
end

The execution of this task is quite slow and I guess it is because in the nested rake-invoke statement the whole rails environment is loaded again.

I wanted to use Rake::Task['...'].invoke instead. But the erd task has some non-rake arguements (filetype=dot etc.), which don't seem to work with the invoke method.

Is there a way to pass those arguments to rake so that I can use the proper rake invoke syntax.


回答1:


Try setting the ENV variables in your code:

task :diagram do
  ENV['filetype']='dot'
  ENV['disconnected'='true'

  Rake::Task['erd'].invoke
end


来源:https://stackoverflow.com/questions/24491583/how-to-invoke-rake-with-non-rake-parameters

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!