question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

feat: Support `nycRC()` in configuration object

See original GitHub issue

I’m toying with programmatically created configurations at @cfware/nyc. This module exports a class with methods implemented as both static factory functions and chainable non-static manipulation functions. The idea is that you could create an nyc.config.js as follows:

'use strict';

module.exports = require('@cfware/nyc')
  .fullCoverage()
  .include('lib/**')
  .exclude('lib/do-not-cover.js')
  .settings;

This example has two main benefits over normal declarative config:

  • .fullCoverage() sets multiple properties (similar to tap --100)
  • .exclude() does not clear defaults so lib/do-not-cover.js is in addition to testExclude.defaultExcludes.

I’d love to avoid having to explicitly use .settings in my nyc.config.js files. This could be supported if the nyc lib/config-util.js did something like:

if (Symbol.for('nycrc') in config) {
  config = config[Symbol.for('nycrc')]
}

In all supported versions of node Symbol.for('nycrc') === Symbol.for('nycrc') so this would allow nyc to pull it’s configuration from config generator objects such as mine. I’ve already verified that adding this code does not break any existing tests.

@bcoe @JaKXz @isaacs any thoughts / objections?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
bcoecommented, May 1, 2019

@coreyfarrell seems reasonable to me 👍; I think what I’ve seen other libraries do is just have the default export be an object with the config (which I think is what we support today if you have an nycrc.js) – what advantages are there to having a toNYCRC() method?

0reactions
coreyfarrellcommented, Dec 30, 2019

Adding support for nyc.config.mjs in nyc 15 has incidentally made this possible. Since we have to await the result of the config load it is now possible for configuration generators to be PromiseLike objects, so:

class ConfigGenerator {
  // Add methods / properties for constructing `this[settings]`

  async then(fn) {
    return fn(await this[settings]);
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js Agent for Google Cloud Debug ChangeLog
This version drops support for Node 4, adds the pathResolver configuration option to support debugging files that have ambiguous paths, and adds a...
Read more >
@istanbuljs/nyc-config-typescript - npm
Handy default configuration for instrumenting your TypeScript-backed project with test coverage using nyc. First install the dependencies: npm i ...
Read more >
parse-server - Gitee
Parse Server is an open source backend that can be deployed to any infrastructure that can run Node.js.
Read more >
@google-cloud/speech | Yarn - Package Manager
Please note that this README.md , the samples/README.md , and a variety of configuration files in this repository (including .nycrc and tsconfig.json )...
Read more >
CHANGES.md - loopbackio/loopback-datasource-juggler
datasource: copy settings object in constructor (Miroslav Bajtoš) ... feat: Support "type" key in sub-properties (Hage Yaapa).
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found