Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run yarn install relative to Rails.root #33819

Merged
merged 1 commit into from
Sep 12, 2018
Merged

Conversation

kevindew
Copy link
Contributor

@kevindew kevindew commented Sep 7, 2018

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.

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.
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants