Merge branch 'pr/3593' into staging/electro-release
commit
ceaffce727
|
@ -49,8 +49,11 @@ class Metasploit::Framework::Command::Base
|
||||||
parsed_options.environment!
|
parsed_options.environment!
|
||||||
ARGV.replace(parsed_options.positional)
|
ARGV.replace(parsed_options.positional)
|
||||||
|
|
||||||
# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/commands.rb#L39-L40
|
# allow other Rails::Applications to use this command
|
||||||
require Pathname.new(__FILE__).parent.parent.parent.parent.parent.join('config', 'application')
|
if !defined?(Rails) || Rails.application.nil?
|
||||||
|
# @see https://github.com/rails/rails/blob/v3.2.17/railties/lib/rails/commands.rb#L39-L40
|
||||||
|
require Pathname.new(__FILE__).parent.parent.parent.parent.parent.join('config', 'application')
|
||||||
|
end
|
||||||
|
|
||||||
# have to configure before requiring environment because
|
# have to configure before requiring environment because
|
||||||
# config/environment.rb calls initialize! and the initializers will use
|
# config/environment.rb calls initialize! and the initializers will use
|
||||||
|
|
|
@ -57,7 +57,7 @@ class Metasploit::Framework::ParsedOptions::Base
|
||||||
#
|
#
|
||||||
# @return [void]
|
# @return [void]
|
||||||
def environment!
|
def environment!
|
||||||
if defined?(Rails) && Rails.instance_variable_defined?(:@_env)
|
if defined?(Rails) && Rails.instance_variable_defined?(:@_env) && Rails.env != options.environment
|
||||||
raise "#{self.class}##{__method__} called too late to set RAILS_ENV: Rails.env already memoized"
|
raise "#{self.class}##{__method__} called too late to set RAILS_ENV: Rails.env already memoized"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -85,14 +85,16 @@ class Metasploit::Framework::ParsedOptions::Base
|
||||||
options.database.disable = false
|
options.database.disable = false
|
||||||
options.database.migrations_paths = []
|
options.database.migrations_paths = []
|
||||||
|
|
||||||
|
# If RAILS_ENV is set, then it will be used, but if RAILS_ENV is set and the --environment option is given, then
|
||||||
|
# --environment value will be used to reset ENV[RAILS_ENV].
|
||||||
|
options.environment = ENV['RAILS_ENV'] || DEFAULT_ENVIRONMENT
|
||||||
|
|
||||||
options.framework = ActiveSupport::OrderedOptions.new
|
options.framework = ActiveSupport::OrderedOptions.new
|
||||||
options.framework.config = nil
|
options.framework.config = nil
|
||||||
|
|
||||||
options.modules = ActiveSupport::OrderedOptions.new
|
options.modules = ActiveSupport::OrderedOptions.new
|
||||||
options.modules.path = nil
|
options.modules.path = nil
|
||||||
|
|
||||||
options.environment = DEFAULT_ENVIRONMENT
|
|
||||||
|
|
||||||
@options = options
|
@options = options
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue