Skip to content
Browse files

Use .railsrc while creating new plugin if available

- Fixes #10700
  • Loading branch information...
1 parent 18b462b commit 4816fdd385b3187b1eaaa2ec4d0026324d631e45 @prathamesh-sonpatki prathamesh-sonpatki committed May 21, 2013
Showing with 19 additions and 0 deletions.
  1. +5 −0 railties/CHANGELOG.md
  2. +14 −0 railties/lib/rails/commands/plugin.rb
View
5 railties/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Uses .railsrc while creating new plugin if it is available.
+ Fixes #10700.
+
+ *Prathamesh Sonpatki*
+
* Remove turbolinks when generating a new application based on a template that skips it.
Example:
View
14 railties/lib/rails/commands/plugin.rb
@@ -2,6 +2,20 @@
ARGV[0] = "--help"
else
ARGV.shift
+ unless ARGV.delete("--no-rc")
+ customrc = ARGV.index{ |x| x.include?("--rc=") }
+ railsrc = if customrc
+ File.expand_path(ARGV.delete_at(customrc).gsub(/--rc=/, ""))
+ else
+ File.join(File.expand_path("~"), '.railsrc')
+ end
+ 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.insert(1, *extra_args)
+ end
+ end
end
require 'rails/generators'

0 comments on commit 4816fdd

Please sign in to comment.
Something went wrong with that request. Please try again.