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.
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