-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Description
Do you want to request a feature or report a bug?
Bug
What is the current behavior?
If cwd
is a subdirectory of $HOME
, .npmrc
and .yarnrc
files will be read multiple times and in the wrong order.
This is because of these lines. Before that block, possibilities
will be [global, home, local]
. But after that block, possibilities
will be [global, home, local, local, ..., home, ...]
with possibilites from intermediate directories (if any).
This is incorrect. Not only will the config files be read multiple times, but values from home
will override those from local
because it read last.
One solution might be as follows:
- Populate
possibilities
with[global, home]
initially - Look for local files starting with
cwd
, but add them in reverse order such that a file located incwd
is last in thepossibilities
array - Only add a config file if it is not already contained in the array
That way we avoid unnecessary reading/parsing and the values have the correct precedence.
If the current behavior is a bug, please provide the steps to reproduce.
- In
$HOME/.npmrc
setregistry=https://registry-a.com
- In
$HOME/repo/.npmrc
setregistry=https://registry-b.com
- In
$HOME/repo
runyarn
Requests will be pulled from https://registry-a.com
.
What is the expected behavior?
Requests should be pulled from https://registry-b.com
.
Please mention your node.js, yarn and operating system version.
Node: v4.6.0
Yarn: master
OS: Windows 10 x64