create-ava icon indicating copy to clipboard operation
create-ava copied to clipboard

Add flags as AVA config instead of CLI flags

Open sindresorhus opened this issue 6 years ago • 3 comments

npm init ava --serial should result in {"ava": {"serial": true}}, not "test": "ava --serial".

@novemberborn ?

sindresorhus avatar Sep 26 '19 09:09 sindresorhus

I assume you'd use this a lot?

  • Which flags would you want to support like this?
  • Which package would hold the knowledge of how those flags map to config?
  • Would this solely update package.json or can it be used to create an ava.config.js as well?
  • Would it help if you could provide, say, a Gist URL which is then written to the appropriate config file (based on extension)?

novemberborn avatar Sep 29 '19 12:09 novemberborn

Which flags would you want to support like this?

All simple flags, so either a primitive or an array of primitives. These can easily be converted without needing custom logic for each option.

The idea was to keep it simple. In create-xo, I did it in a few LOC: https://github.com/xojs/create-xo/blob/598d18fbf28ee5a8db4b131f7a38e6a24dd61dba/index.js#L67-L79

Which package would hold the knowledge of how those flags map to config?

This

Would this solely update package.json or can it be used to create an ava.config.js as well?

We could add an option to create an ava.config.js instead of updating package.json, yes.

Would it help if you could provide, say, a Gist URL which is then written to the appropriate config file (based on extension)?

For what purpose? Sharing common config?

sindresorhus avatar Sep 29 '19 14:09 sindresorhus

Which flags would you want to support like this?

All simple flags, so either a primitive or an array of primitives. These can easily be converted without needing custom logic for each option.

OK. Though IIRC we don't have flags that take arrays anymore.

Which package would hold the knowledge of how those flags map to config?

This

:+1:

Would this solely update package.json or can it be used to create an ava.config.js as well?

We could add an option to create an ava.config.js instead of updating package.json, yes.

Yes, let's.

Would it help if you could provide, say, a Gist URL which is then written to the appropriate config file (based on extension)?

For what purpose? Sharing common config?

Just exploring alternative solutions. But I'm happy with what you're proposing.

novemberborn avatar Sep 30 '19 07:09 novemberborn