diff options
author | Kasper Timm Hansen <kaspth@gmail.com> | 2016-08-07 17:09:29 +0200 |
---|---|---|
committer | Kasper Timm Hansen <kaspth@gmail.com> | 2016-08-07 17:09:29 +0200 |
commit | ff8035dfeed8c86594c32ef8e9204806e190cb58 (patch) | |
tree | b06bdba04dbf879dbcf7d63da06680bb3fa25f7b /railties/lib/rails/commands | |
parent | 8f26f31934b4f0c694a081d2a89996f3935768d1 (diff) | |
download | rails-ff8035dfeed8c86594c32ef8e9204806e190cb58.tar.gz rails-ff8035dfeed8c86594c32ef8e9204806e190cb58.tar.bz2 rails-ff8035dfeed8c86594c32ef8e9204806e190cb58.zip |
Defer requiring Rake until it's needed.
Eagerly requiring Rake could put 100ms on to the Rails boot time. Shimmy that
down to 0 by requiring Rake when no native Rails command exists and we try to
run a Rake task. Or when printing all the Rake commands through `rails help`.
Fixes #25029
Diffstat (limited to 'railties/lib/rails/commands')
-rw-r--r-- | railties/lib/rails/commands/rake_proxy.rb | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/railties/lib/rails/commands/rake_proxy.rb b/railties/lib/rails/commands/rake_proxy.rb index ad5249ff48..b9e50f3e5a 100644 --- a/railties/lib/rails/commands/rake_proxy.rb +++ b/railties/lib/rails/commands/rake_proxy.rb @@ -1,10 +1,11 @@ -require "rake" require "active_support" module Rails module RakeProxy #:nodoc: private def run_rake_task(command) + require_rake + ARGV.unshift(command) # Prepend the command, so Rake knows how to run it. Rake.application.standard_exception_handling do @@ -15,6 +16,8 @@ module Rails end def rake_tasks + require_rake + return @rake_tasks if defined?(@rake_tasks) ActiveSupport::Deprecation.silence do @@ -30,5 +33,9 @@ module Rails def formatted_rake_tasks rake_tasks.map { |t| [ t.name_with_args, t.comment ] } end + + def require_rake + require "rake" # Defer booting Rake until we know it's needed. + end end end |