-
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
Read config from ~/.yarnrc #5812
Changes from 2 commits
b88afa4
4df15f9
b79101f
acc231c
04cbc49
6a83cea
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -298,8 +298,7 @@ export default class NpmRegistry extends Registry { | |
} | ||
|
||
for (const scope of [this.getScope(packageIdent), '']) { | ||
const registry = | ||
this.getScopedOption(scope, 'registry') || this.registries.yarn.getScopedOption(scope, 'registry'); | ||
const registry = this.getScopedOption(scope, 'registry'); | ||
if (registry) { | ||
return String(registry); | ||
} | ||
|
@@ -347,7 +346,24 @@ export default class NpmRegistry extends Registry { | |
} | ||
|
||
getScopedOption(scope: string, option: string): mixed { | ||
return this.getOption(scope + (scope ? ':' : '') + option); | ||
const key = scope + (scope ? ':' : '') + option; | ||
|
||
let val = this.getOption(key); | ||
|
||
if (typeof val === 'undefined') { | ||
const registries = Object.keys(this.registries); | ||
for (const registryName of registries) { | ||
if (this.registries[registryName].getOption) { | ||
val = this.registries[registryName].getOption(key); | ||
} | ||
|
||
if (typeof val !== 'undefined') { | ||
break; | ||
} | ||
} | ||
} | ||
|
||
return val; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you think it will be possible to swap this for an implementation of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe that would turn into endless recursion.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sorry, I'll clarify my meaning. How aboutif we implement getScopedOption(scope: string, option: string): mixed {
return this.getOption(scope + (scope ? ':' : '') + option);
} There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I could look into moving all the logic into There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we can start by adding a test for this and then playing around to see what works best. It'll be much easier that way. Makes sense? |
||
} | ||
|
||
getRegistryOption(registry: string, option: string): mixed { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YarnRegistry.getScopedOption
does not exist.