Pass `rails runner` args onto file again.
When making the new command insfrastructure I had missed that `bin/rails runner some_file.rb some args` would pass the extra args onto the file in `ARGV`. Now fixed by allowing the command to take extra args again, and make sure to remove the file name from `ARGV`.
This commit is contained in:
parent
e6c808e354
commit
5aea0952e7
|
@ -14,7 +14,7 @@ module Rails
|
|||
"#{super} [<'Some.ruby(code)'> | <filename.rb>]"
|
||||
end
|
||||
|
||||
def perform(code_or_file = nil)
|
||||
def perform(code_or_file = nil, *file_argv)
|
||||
unless code_or_file
|
||||
help
|
||||
exit 1
|
||||
|
@ -27,6 +27,7 @@ module Rails
|
|||
|
||||
if File.exist?(code_or_file)
|
||||
$0 = code_or_file
|
||||
ARGV.replace(file_argv)
|
||||
Kernel.load code_or_file
|
||||
else
|
||||
begin
|
||||
|
|
|
@ -68,6 +68,14 @@ module ApplicationTests
|
|||
assert_match "bin/program_name.rb", Dir.chdir(app_path) { `bin/rails runner "bin/program_name.rb"` }
|
||||
end
|
||||
|
||||
def test_passes_extra_args_to_file
|
||||
app_file "bin/program_name.rb", <<-SCRIPT
|
||||
p ARGV
|
||||
SCRIPT
|
||||
|
||||
assert_match %w( a b ).to_s, Dir.chdir(app_path) { `bin/rails runner "bin/program_name.rb" a b` }
|
||||
end
|
||||
|
||||
def test_with_hook
|
||||
add_to_config <<-RUBY
|
||||
runner do |app|
|
||||
|
|
Loading…
Reference in New Issue