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

fallback to npm config if it exists after getting default yarn config value #871

Merged
merged 1 commit into from
Oct 12, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/registries/yarn-registry.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,15 @@ export default class YarnRegistry extends NpmRegistry {
homeConfig: Object;

getOption(key: string): mixed {
return this.config[key] || this.registries.npm.getOption(npmMap[key] || key);
let val = this.config[key] || this.registries.npm.getOption(npmMap[key]);

// if we have no yarn option for this or have used a default then use the npm
// value if it exists
if (!val || val === DEFAULTS[key]) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this code, if the value is the same as the default, it will favor the npm config even if the user explicitly set it. Shouldn't an explicit setting still take precedence over the npm config value?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we might want to check if it's undefined instead of just falsy, since the user could also explicitly specify a falsy value.

val = this.registries.npm.getOption(key) || val;
}

return val;
}

async loadConfig(): Promise<void> {
Expand Down