Skip to content

Conversation

yatharthx
Copy link
Contributor

Fixes #1046

This separates out package config keys from CLI flags by picking up defaults from conf and passing them to meow as defaults. Furthermore, the resultant cli.flags is copied back conf so that it can be used elsewhere (instead of cli.flags).

@novemberborn The changes have been made as per our discussion about the same. Let me know if something doesn't seems like fitting in right!

Copy link
Member

@novemberborn novemberborn left a comment

Choose a reason for hiding this comment

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

Looks good! Just some small nits 😄

lib/cli.js Outdated
timeout: conf.timeout,
concurrency: conf.concurrency,
updateSnapshots: conf.updateSnapshots,
color: true || conf.color
Copy link
Member

Choose a reason for hiding this comment

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

I think this should be 'color' in conf ? color.conf : true. The idea is that it defaults to true if not configured at all, but otherwise the config value should prevail.

It's strange that this doesn't fail any tests though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, I don't know how I missed out on this. Was stupid! 😛 So what you're suggesting here is something like color: conf.color ? conf.color : true, right?

Copy link
Member

Choose a reason for hiding this comment

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

No, that'll still force the value to be true if conf.color is false.

If color is in conf, assume it's a usable value, else use true.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I get it. Then I guess we can use (conf.color !== undefined) ? conf.color : true. Any thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Why not 'color' in conf ? color.conf : true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool. No problem. I wasn't so sure about that. You just enhanced my knowledge. Thank you. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I pushed the changes. You can check them now!

concurrency: conf.concurrency,
updateSnapshots: conf.updateSnapshots,
color: true || conf.color
},
Copy link
Member

Choose a reason for hiding this comment

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

Would you mind sorting the keys alphabetically?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure. 👍

lib/cli.js Outdated
}

// copy resultant cli.flags into conf for use with Api and elsewhere
conf = Object.assign(conf, cli.flags);
Copy link
Member

Choose a reason for hiding this comment

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

Object.assign(conf, …) modifies and returns conf. There's no need to reassign it (since you're reassigning it to itself).

@sindresorhus sindresorhus changed the title separate config keys from CLI flags Separate config keys from CLI flags Mar 11, 2017
@sindresorhus sindresorhus merged commit 6eae738 into avajs:master Mar 14, 2017
@sindresorhus
Copy link
Member

Nice work @yatharthk 👌

@yatharthx
Copy link
Contributor Author

@sindresorhus Happy to contribute 😄. Thanks to @novemberborn for all the help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants