提交 19ca0952 编写于 作者: A Aaron Patterson

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

上级 36ea8e6a
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册