fix(run): change run command to prioritize cwd/node_modules/.bin #7750
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This change builds off of #7151 and fixes #7748.
The issue is that when a binary is hoisted and also installed in a workspace package,
yarn bin
andyarn run
(from the workspace package) fail to use the correct binary (they use the hoisted binary instead of the locally installed binary).This PR just changes the order in which the array of paths is built so that the CWD bin path has a higher precedence than the hoisted bin path.
Test plan
Added two new tests that verify the correct binary is executed when running
yarn run
. One test has the same binary installed in a workspace package and hoisted to the root. The other test just has a binary hoisted to the root. Both tests try to run their binaries from a workspace package and verify that the right binary was used.