Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit e093212

Browse files
committed
Revert the previous commit and backport the ruby_rake_task method
It is better that requirejs:precompile:all runs in a fresh Rake process, so as not to clobber the parent Rake process' environment.
1 parent 501553d commit e093212

File tree

1 file changed

+14
-2
lines changed

1 file changed

+14
-2
lines changed

lib/tasks/requirejs-rails_tasks.rake

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,26 @@ require 'tempfile'
1010
require 'active_support/ordered_options'
1111

1212
namespace :requirejs do
13+
# This method was backported from an earlier version of Sprockets.
14+
def ruby_rake_task(task)
15+
env = ENV["RAILS_ENV"] || "production"
16+
groups = ENV["RAILS_GROUPS"] || "assets"
17+
args = [$0, task, "RAILS_ENV=#{env}", "RAILS_GROUPS=#{groups}"]
18+
args << "--trace" if Rake.application.options.trace
19+
ruby *args
20+
end
1321

1422
# From Rails 3 assets.rake; we have the same problem:
1523
#
1624
# We are currently running with no explicit bundler group
1725
# and/or no explicit environment - we have to reinvoke rake to
1826
# execute this task.
1927
def invoke_or_reboot_rake_task(task)
20-
Rake::Task[task].invoke
28+
if ENV['RAILS_GROUPS'].to_s.empty? || ENV['RAILS_ENV'].to_s.empty?
29+
ruby_rake_task task
30+
else
31+
Rake::Task[task].invoke
32+
end
2133
end
2234

2335
requirejs = ActiveSupport::OrderedOptions.new
@@ -78,7 +90,7 @@ EOM
7890
# We depend on test_node here so we'll fail early and hard if node
7991
# isn't available.
8092
task :external => ["requirejs:test_node"] do
81-
Rake::Task["requirejs:precompile:all"].invoke
93+
ruby_rake_task "requirejs:precompile:all"
8294
end
8395

8496
# copy all assets to tmp/assets

0 commit comments

Comments
 (0)