-
-
Save FeepingCreature/1d36973be5facde89fa7e2e338245713 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def patch_argv | |
# remove everything after -- so rake doesn't get confused and think it's tasks | |
# save it in EXTRA_ARGS | |
sep = ARGV.index("--") || ARGV.length | |
real_args, extra_args = ARGV.take(sep), ARGV.drop(sep + 1) | |
ARGV.clear | |
real_args.each { |arg| ARGV << arg } | |
# erroneously, rake will have interpreted the words after -- as tasks | |
# so now we get to remove them manually | |
rake_tasks = Rake.application.top_level_tasks | |
extra_args.each do |arg| | |
# remove from back to arg | |
pos = rake_tasks.rindex arg | |
if pos | |
rake_tasks = rake_tasks.take(pos) | |
end | |
end | |
Rake.application.instance_variable_set(:@top_level_tasks, rake_tasks) | |
extra_args | |
end | |
EXTRA_ARGS = patch_argv |
Nakilon
commented
Mar 26, 2021
•
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment