diff --git a/actionpack/lib/sprockets/assets.rake b/actionpack/lib/sprockets/assets.rake index b2c282c158..a68f0e84f8 100644 --- a/actionpack/lib/sprockets/assets.rake +++ b/actionpack/lib/sprockets/assets.rake @@ -1,16 +1,16 @@ namespace :assets do - desc "Compile all the assets named in config.assets.precompile" - task :precompile do - if ENV["RAILS_GROUPS"].to_s.empty? - ENV["RAILS_GROUPS"] = "assets" - Kernel.exec $0, *ARGV - else - Rake::Task["environment"].invoke - Sprockets::Helpers::RailsHelper + # Ensures the RAILS_GROUPS environment variable is set + task :ensure_env do + ENV["RAILS_GROUPS"] ||= "assets" + end - assets = Rails.application.config.assets.precompile - Rails.application.assets.precompile(*assets) - end + desc "Compile all the assets named in config.assets.precompile" + task :precompile => :ensure_env do + Rake::Task["environment"].invoke + Sprockets::Helpers::RailsHelper + + assets = Rails.application.config.assets.precompile + Rails.application.assets.precompile(*assets) end desc "Remove compiled assets"