Skip to content

Commit

Permalink
feat: Add support for env.NYC_CONFIG_OVERRIDE (#1077)
Browse files Browse the repository at this point in the history
This allows a process to spawn a child process with an environment
variable NYC_CONFIG_OVERRIDE.  This is a JSON string which overrides any
values in the NYC_CONFIG env.  It is not deleted in the child process,
so will be contagious unless unset, and it is the responsibility of the
caller to manage.

The first intended use case of this feature is to allow node-tap to map
tests to the specific portion of a system under test that they cover.
In this way, unit tests can be more focused, and only re-run when their
specific unit has changed.

There are, of course, many other uses that this could be put to, and it
did not seem appropriate to add a special hook _just_ for overriding
the include list.
  • Loading branch information
isaacs authored and coreyfarrell committed Apr 24, 2019
1 parent 6fc109f commit 132a074
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 1,043 deletions.
6 changes: 6 additions & 0 deletions bin/wrap.js
Expand Up @@ -16,6 +16,12 @@ if (process.env.NYC_PROCESSINFO_EXTERNAL_ID) {
delete process.env.NYC_PROCESSINFO_EXTERNAL_ID
}

if (process.env.NYC_CONFIG_OVERRIDE) {
var override = JSON.parse(process.env.NYC_CONFIG_OVERRIDE)
config = Object.assign(config, override)
process.env.NYC_CONFIG = JSON.stringify(config)
}

;(new NYC(config)).wrap()

sw.runMain()

0 comments on commit 132a074

Please sign in to comment.