aboutsummaryrefslogtreecommitdiffstats
path: root/railties/lib/rails/tasks
diff options
context:
space:
mode:
authorprintercu <printercu@gmail.com>2018-04-23 20:16:30 +0300
committerMax Melentiev <melentievm@gmail.com>2018-04-23 20:37:26 +0300
commit8e9186d241f24fe01a96a321900a182bc581c24e (patch)
treedbb4a6dcc86e918f00fbdbebc3b867a823b8c2d7 /railties/lib/rails/tasks
parentcde7c30781e45dab23ff6be8d5b83b3c67344b64 (diff)
downloadrails-8e9186d241f24fe01a96a321900a182bc581c24e.tar.gz
rails-8e9186d241f24fe01a96a321900a182bc581c24e.tar.bz2
rails-8e9186d241f24fe01a96a321900a182bc581c24e.zip
Respect NODE_ENV when running `rails yarn:install`
`yarn install --prod` removes dev deps, so it's impossible to run `assets:precompile` with dev npm dependencies. This change makes rake task pass NODE_ENV to yarn when explicitly set.
Diffstat (limited to 'railties/lib/rails/tasks')
-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