aboutsummaryrefslogtreecommitdiffstats
path: root/railties
diff options
context:
space:
mode:
authorKevin Dew <kevindew@me.com>2018-09-07 21:58:10 +0100
committerKevin Dew <kevindew@me.com>2018-09-07 22:11:10 +0100
commitf443aac3402dc2dd294f3ed8b0c4b20b9859b169 (patch)
treed0697fddc14050306ccd30a70f168c3749b039dd /railties
parentdd29fabebf1b702031213361b7757be5892cd59f (diff)
downloadrails-f443aac3402dc2dd294f3ed8b0c4b20b9859b169.tar.gz
rails-f443aac3402dc2dd294f3ed8b0c4b20b9859b169.tar.bz2
rails-f443aac3402dc2dd294f3ed8b0c4b20b9859b169.zip
Run yarn install relative to Rails.root
We may not always have binstubs relative to the directory we are running the rake task from. The particular case for this is with a mountable Rails engine and dummy app that is created to test it. This sets all the tasks up to run under an `app` namespace in railties/lib/rails/tasks/engine.rake This change resolves a problem whereby running `app:yarn:install` would have no effect as it would try to run in the plugins bin directory rather than the test/dummy/bin. This also means that it installs from test/dummy/package.json and into test/dummy/node_modules which is behaviour consistent with a normal Rails app. On a rails engine: ``` ➜ tmp rails plugin new rails-plugin --mountable ➜ tmp cd rails-plugin ``` Before this change: ``` ➜ rails-plugin rake app:yarn:install ➜ rails-plugin ``` After this change: ``` ➜ rails-plugin rake app:yarn:install yarn install v1.9.4 info No lockfile found. [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 📃 Building fresh packages... ✨ Done in 0.07s. ``` When this change is ran against a normal rails install there is not a behavioural change: ``` ➜ tmp rails new full-app ➜ tmp cd full-app ➜ full-app git:(master) ✗ rake yarn:install yarn install v1.9.4 info No lockfile found. [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 📃 Building fresh packages... ✨ Done in 0.09s. ```
Diffstat (limited to 'railties')
-rw-r--r--railties/lib/rails/tasks/yarn.rake2
1 files changed, 1 insertions, 1 deletions
diff --git a/railties/lib/rails/tasks/yarn.rake b/railties/lib/rails/tasks/yarn.rake
index cf45a392e8..4fb8586b69 100644
--- a/railties/lib/rails/tasks/yarn.rake
+++ b/railties/lib/rails/tasks/yarn.rake
@@ -9,7 +9,7 @@ namespace :yarn 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")
+ system({ "NODE_ENV" => node_env }, "#{Rails.root}/bin/yarn install --no-progress --frozen-lockfile")
end
end