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

Extend .nycrc configurations #503

Closed
rcoy-v opened this issue Jan 24, 2017 · 5 comments
Closed

Extend .nycrc configurations #503

rcoy-v opened this issue Jan 24, 2017 · 5 comments

Comments

@rcoy-v
Copy link

rcoy-v commented Jan 24, 2017

Other tools that have similar uses of .rc configuration files, like Babel and ESLint, allow you to extend other configuration files. This is a useful option for configuration reuse, when you want to keep mostly the same configuration in multiple projects, and only override a few options.

It doesn't appear that nyc supports this currently. Below is an example of what I would like to do:

node_modules/my-lib/.nycrc

{
    "lines": 95,
    "statements": 95,
    "functions": 95,
    "branches": 95,
    "reporter": [
        "cobertura",
        "lcov"
    ],
    "all": false,
    "check-coverage": true,
    "report-dir": "./coverage",
    "cache": false
}

.nycrc

{
  "extends": "./node_modules/my-lib/.nycrc",
  "lines": 80
}
@JaKXz
Copy link
Member

JaKXz commented Jan 24, 2017

@rcoy-v I'd go one further and say:

{
  "extends": "my-lib",
  "lines": 80
}

and you could optionally specify a relative path instead of the module name.

That being said, I think this is a great suggestion! Feel free to take a crack at a PR, but if not hopefully I can take a look later this week.

@bcoe
Copy link
Member

bcoe commented Jan 29, 2017

@JaKXz I like this idea too, but one thing comes to mind @rcoy-v; why don't we add this functionality to yargs' config handling and open a feature request on yargs, rather than implementing the extend option in nyc.

One side-goal I've had with nyc is to try to use it to hammer on yargs, and figure out clean abstractions for a complex CLI application.

@rcoy-v
Copy link
Author

rcoy-v commented Jan 30, 2017

@bcoe To make sure I understand, you are suggesting the syntax for extending configurations is fine. What implements the merging of configuration extensions is yargs, not nyc directly. That is to make extending functionality reusable to any project.

If that is correct, I'm fine either way on where it is implemented.

@bcoe
Copy link
Member

bcoe commented Jan 30, 2017

@rcoy-v yeah; I like the syntax, especially if other projects are converging on it. But it would be nice to implement it in yargs if possible, so that anyone using yargs for loading rc files gets the functionality.

@bcoe
Copy link
Member

bcoe commented May 27, 2017

@rcoy-v sorry this took so long to build; I really appreciate the work, and I I feel the feature turned out really slick; here's an example:

https://www.npmjs.com/package/@istanbuljs/nyc-config-babel

You can now try things out on the next release candidate of nyc:

npm cache clear; npm i nyc@next

👍

@bcoe bcoe closed this as completed May 27, 2017
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 a pull request may close this issue.

3 participants