aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2018-05-22 17:48:57 -0400
committerGitHub <noreply@github.com>2018-05-22 17:48:57 -0400
commit9480618f06ada9e06e8c95ca85d6242debad693a (patch)
treeaec7a446ca647ec919887ebd374b2f4b5221bfeb /railties
parent2b2bf2c73bf37dfc8587aa531de0e88d16769630 (diff)
parent8e9186d241f24fe01a96a321900a182bc581c24e (diff)
downloadrails-9480618f06ada9e06e8c95ca85d6242debad693a.tar.gz
rails-9480618f06ada9e06e8c95ca85d6242debad693a.tar.bz2
rails-9480618f06ada9e06e8c95ca85d6242debad693a.zip
Merge pull request #32699 from printercu/patch-3
Respect NODE_ENV when running `rails yarn:install`
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/tasks/yarn.rake8
1 files changed, 7 insertions, 1 deletions
diff --git a/railties/lib/rails/tasks/yarn.rake b/railties/lib/rails/tasks/yarn.rake
index 10703a1808..cf45a392e8 100644
--- a/railties/lib/rails/tasks/yarn.rake
+++ b/railties/lib/rails/tasks/yarn.rake
@@ -3,7 +3,13 @@
namespace :yarn do
desc "Install all JavaScript dependencies as specified via Yarn"
task :install do
- system("./bin/yarn install --no-progress --frozen-lockfile --production")
+ # Install only production deps when for not usual envs.
+ valid_node_envs = %w[test development production]
+ node_env = ENV.fetch("NODE_ENV") do
+ rails_env = ENV["RAILS_ENV"]
+ valid_node_envs.include?(rails_env) ? rails_env : "production"
+ end
+ system({ "NODE_ENV" => node_env }, "./bin/yarn install --no-progress --frozen-lockfile")
end
end