Skip to content

Commit

Permalink
Merge pull request #32699 from printercu/patch-3
Browse files Browse the repository at this point in the history
Respect NODE_ENV when running `rails yarn:install`
  • Loading branch information
rafaelfranca committed May 22, 2018
1 parent 50bc256 commit 40ef775
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion railties/lib/rails/tasks/yarn.rake
Expand Up @@ -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 --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")
end
end

Expand Down

0 comments on commit 40ef775

Please sign in to comment.