1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #32699 from printercu/patch-3

Respect NODE_ENV when running `rails yarn:install`
This commit is contained in:
Rafael França 2018-05-22 17:48:57 -04:00 committed by GitHub
commit 9480618f06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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