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

Allow --nycrc-path to be absolute #1073

Closed
ehmicky opened this issue Apr 17, 2019 · 8 comments
Closed

Allow --nycrc-path to be absolute #1073

ehmicky opened this issue Apr 17, 2019 · 8 comments

Comments

@ehmicky
Copy link

ehmicky commented Apr 17, 2019

At the moment --nycrc-path value must be relative. It would be great if this could be absolute as well.

My use case: I have a module with shared development tasks that I use in many libraries. One of those tasks is running tests with nyc. The nyc configuration is always the same, i.e. I want to specify it inside that shared module instead of inside each library.

I cannot use --cwd as it would impact test coverage (not just configuration loading). I.e. I need to use __dirname with an absolute path.

My current workaround is to use CLI flags instead of a configuration file, but a configuration file would be better.

@coreyfarrell
Copy link
Member

I'm looking into creating a proper fix for this. That said I would recommend instead using nyc.extends in your package.json instead of using any CLI flags. So in your package.json:

{
  "nyc": {
    "extends": "@my-org/nyc-config"
  }
}

You would also run npm i -D @my-org/nyc-config, obviously replace that module name with whatever name publish your shared config under.

@ehmicky
Copy link
Author

ehmicky commented Apr 17, 2019

Thanks that would work. However I am trying to abstract any development tool in that shared module. I.e. when development tooling changes, my libraries don't need to be updated.

I.e. I am avoiding adding any configuration property or file related to development/build tasks in my libraries, and instead only point to that shared module.

@coreyfarrell
Copy link
Member

Not following the last statement, you need to add --nycrc-path somewhere, wouldn't that be in your npm test script? It might help me understand if you pointed to an example repo.

@ehmicky
Copy link
Author

ehmicky commented Apr 17, 2019

Each of my libraries install a module gulp-shared-tasks as a devDependency. They also have a gulpfile.js that just require that module.

gulp-shared-tasks exports several Gulp tasks, including gulp unit, which basically runs nyc ava test/.

Links to: gulp-shared-tasks, a library that uses it and the line of code that actually calls nyc.

The reason of the setup is I am trying to reduce repeated code between libraries to the minimum. This includes not only code, but also configuration properties/files. I even try to remove configuration files that merely forward to another module.

@coreyfarrell
Copy link
Member

@ehmicky this will be supported by the next release of find-up, once that is released and we upgrade this issue will be fixed. The next version of find-up will require node.js 8 so the plan is that this will be fixed in nyc@15. I can't promise 15.0.0, it depends on when the next find-up release occurs.

@ehmicky
Copy link
Author

ehmicky commented May 6, 2019

@coreyfarrell thanks for the update and the work downstream with that PR on find-up!

@coreyfarrell
Copy link
Member

The new release of find-up has been made and will fix this issue once we're able to release nyc@15. I'm going to close this issue as no further action will happen here, bumping find-up will happen as part of a mass dependency update. Please follow #1104 for progress updates about the next release of nyc.

@ehmicky
Copy link
Author

ehmicky commented May 28, 2019

Thanks, that's great!

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

No branches or pull requests

3 participants