Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

there is no reason for ARGV[0] to be nil

  • Loading branch information...
commit 19ca0952bbdcf744f12d2bedb267dff20618e149 1 parent 36ea8e6
@tenderlove tenderlove authored
View
18 railties/lib/rails/generators/rails/app/app_generator.rb
@@ -362,15 +362,17 @@ def railsrc(argv)
end
end
+ def read_rc_file(railsrc)
+ return [] unless File.exists?(railsrc)
+ extra_args_string = File.read(railsrc)
+ extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten
+ puts "Using #{extra_args.join(" ")} from #{railsrc}"
+ extra_args
+ end
+
def insert_railsrc_into_argv!(argv, railsrc)
- if File.exist?(railsrc)
- extra_args_string = File.read(railsrc)
- extra_args = extra_args_string.split(/\n+/).map {|l| l.split}.flatten
- puts "Using #{extra_args.join(" ")} from #{railsrc}"
- [argv.first] + extra_args + argv.drop(1)
- else
- argv
- end
+ extra_args = read_rc_file railsrc
+ argv.take(1) + extra_args + argv.drop(1)
end
end
end
View
4 railties/test/generators/argv_scrubber_test.rb
@@ -67,7 +67,7 @@ def test_new_homedir_rc
define_method(:puts) { |msg| message = msg }
}.new ['new']
args = scrubber.prepare!
- assert_equal [nil, '--hello-world'], args
+ assert_equal ['--hello-world'], args
assert_match 'hello-world', message
assert_match file.path, message
ensure
@@ -85,7 +85,7 @@ def test_new_rc_option
define_method(:puts) { |msg| message = msg }
}.new ['new', "--rc=#{file.path}"]
args = scrubber.prepare!
- assert_equal [nil, '--hello-world'], args
+ assert_equal ['--hello-world'], args
assert_match 'hello-world', message
assert_match file.path, message
ensure
Please sign in to comment.
Something went wrong with that request. Please try again.