-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
prefer local config to home and home to global #951
prefer local config to home and home to global #951
Conversation
Fixes #949 |
@FLGMwt I think your example is accidentally confusing - one of those config files should be |
This will fix the behavior for setting config values, but it won't prevent reading/parsing the same file multiple times (potentially). Heck, even starting at const foldersFromRootToCwd = this.cwd.split(path.sep).slice(0, -1); // start at {cwd}/..
while (foldersFromRootToCwd.length > 1) {
possibles.push([false, path.join(foldersFromRootToCwd.join(path.sep), filename)]);
foldersFromRootToCwd.pop();
} |
good catch on the example @jgoz. Fixed |
And wrt I just tried nesting a project with a .npmrc inside of a project with an .npmrc and when I removed the inner .npmrc, the one in the parent directory wasn't respected. (with |
Yeah, that's because the home and global configs would take precedence (since it's using
Right, I looked that up too and |
Sorry for not being clear: my last comment was me checking the behavior of npm and not yarn. I was making sure that npm didn't actually look up from Before I fix |
My fault, I'm so eager to drop
I would vote to remove it to keep things simple, but it could be useful/used in multi-repos (like babel, react) to have a single config for multiple sub projects. |
For monorepos/multi-repos, it might be good to just have a per-file option like On the other hand, if the files we're loading are just |
Summary
#949
Right now, config resolution favors global, and only uses more local configs if those contain keys undefined in more global configs.
For example,
If i have
and
then
yarn config list
outputs the following:Test plan
With changes reordering the config resolution,
yarn config list
outputs the following: