You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
$RAKE_PRELOAD to load custom Ruby file before starting application #595
Rake application loads Rakefile AFTER Rake.application.run() started.
Therefore it is not able to customize Rake.application.run() (or other methods defined in Rake.application) in Rakefile.
For example, I want to change Rake::Application#handle_options() to use parser.order(argv) instead of parser.parse(argv) in order not to parse options after task names.
(I'm developing rake extension to allow command-line options for each task, and parser.order() is necessary for this purpose.)
Here is my challenge (Rakefile):
## RakefilemoduleRakeApplication.class_evaldodefhandle_options(argv)set_default_optionsOptionParser.newdo |opts|
opts.banner="#{Rake.application.name} [-f rakefile] {options} targets..."opts.separator""opts.separator"Options are ..."opts.on_tail("-h","--help","-H","Display this help message.")doputsoptsexitendstandard_rake_options.each{ |args| opts.on(*args)}opts.environment("RAKEOPT")#end.parse(argv) # !! original !!end.order(argv)# !! customize !!endendend
But the above Rakefile doesn't work intendedly because Rake application loads Rakefile after Rake.application.run() started.
Therefore, I hope Rake to provide a certain method to load custom ruby file before Rake.application.run() started.
One solution is to load a ruby file specified by the $RAKE_PRELOAD environment variable in rake command.
Activity