Configure generator when needed rather than during initialization
This commit is contained in:
parent
d627c932bd
commit
a3d5274e67
|
@ -412,18 +412,6 @@ module Rails
|
|||
end
|
||||
end
|
||||
|
||||
# Configure generators if they were already loaded
|
||||
# ===
|
||||
# TODO: Does this need to be an initializer here?
|
||||
initializer :initialize_generators do
|
||||
if defined?(RAILS_GENERATORS) && RAILS_GENERATORS
|
||||
require 'rails/generators'
|
||||
Rails::Generators.no_color! unless config.generators.colorize_logging
|
||||
Rails::Generators.aliases.deep_merge! config.generators.aliases
|
||||
Rails::Generators.options.deep_merge! config.generators.options
|
||||
end
|
||||
end
|
||||
|
||||
# For each framework, search for instrument file with Notifications hooks.
|
||||
#
|
||||
initializer :load_notifications_hooks do
|
||||
|
|
|
@ -72,6 +72,12 @@ module Rails
|
|||
}
|
||||
}
|
||||
|
||||
def self.configure!(config = Rails.application.config.generators) #:nodoc:
|
||||
no_color! unless config.colorize_logging
|
||||
aliases.deep_merge! config.aliases
|
||||
options.deep_merge! config.options
|
||||
end
|
||||
|
||||
def self.aliases #:nodoc:
|
||||
@aliases ||= DEFAULT_ALIASES.dup
|
||||
end
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<%= shebang %>
|
||||
RAILS_GENERATORS = true
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
require 'rails/generators'
|
||||
Rails::Generators.configure!
|
||||
require 'rails/commands/destroy'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<%= shebang %>
|
||||
RAILS_GENERATORS = true
|
||||
require File.expand_path('../../config/environment', __FILE__)
|
||||
require 'rails/generators'
|
||||
Rails::Generators.configure!
|
||||
require 'rails/commands/generate'
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
require "isolation/abstract_unit"
|
||||
RAILS_GENERATORS = true
|
||||
|
||||
module ApplicationTests
|
||||
class GeneratorsTest < Test::Unit::TestCase
|
||||
|
@ -47,6 +46,7 @@ module ApplicationTests
|
|||
end
|
||||
# Initialize the application
|
||||
Rails.initialize!
|
||||
Rails::Generators.configure!
|
||||
|
||||
assert_equal :rspec, Rails::Generators.options[:rails][:test_framework]
|
||||
assert_equal "-w", Rails::Generators.aliases[:rails][:test_framework]
|
||||
|
@ -59,6 +59,7 @@ module ApplicationTests
|
|||
end
|
||||
# Initialize the application
|
||||
Rails.initialize!
|
||||
Rails::Generators.configure!
|
||||
|
||||
assert_equal Thor::Base.shell, Thor::Shell::Basic
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue