Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: istanbuljs/nyc
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v13.3.0
Choose a base ref
...
head repository: istanbuljs/nyc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v14.0.0
Choose a head ref

Commits on Feb 14, 2019

  1. chore: Update package-lock.json for security audit.

    Update so `tap` pulls nyc@13.3.0 to avoid the vulnerable handlebars
    provided by nyc@13.2.0.  This causes the security audit to be clean for
    development installs.
    coreyfarrell committed Feb 14, 2019
    Copy the full SHA
    12b8986 View commit details

Commits on Feb 20, 2019

  1. Copy the full SHA
    509c6aa View commit details

Commits on Feb 22, 2019

  1. fix: Exclude negated not working with '--all' switch (#977)

    * Add tests for nyc --all negated excludes
    * Update file walker to allow negated excludes
    
    Previously the call to glob.sync was knocking out all files in the exclude patterns,
    this would also knock out any files that were intended to be restored by the exclude negated patterns.
    This would prevent node_modules exclude negated files from being covered when run with --all.
    AndrewFinlay authored and coreyfarrell committed Feb 22, 2019
    Copy the full SHA
    91de23c View commit details
  2. Copy the full SHA
    c017bf9 View commit details
  3. chore(test): consolidate on tap test runner, stop running build step (#…

    …997)
    
    * remove build step from tests
    * address standard nits
    * remove forking-tap dependency
    * increase tap timeout now that we have bigger test files
    bcoe authored and coreyfarrell committed Feb 22, 2019
    Copy the full SHA
    5d5f340 View commit details
  4. Copy the full SHA
    7b5dad5 View commit details

Commits on Feb 27, 2019

  1. fix: add config values to hash salt (#988)

    Fixes #522
    taye authored and coreyfarrell committed Feb 27, 2019
    Copy the full SHA
    7ac325d View commit details
  2. Copy the full SHA
    b64d921 View commit details

Commits on Mar 4, 2019

  1. Copy the full SHA
    0d7fcb7 View commit details

Commits on Mar 5, 2019

  1. Copy the full SHA
    a161d23 View commit details

Commits on Mar 7, 2019

  1. Copy the full SHA
    3cb1861 View commit details
  2. feat: Enable es-modules option for nyc instrument command (#1006)

    BREAKING CHANGE: `nyc instrument` now enables the `--es-module` option by default.
    AndrewFinlay authored and coreyfarrell committed Mar 7, 2019
    Copy the full SHA
    596b120 View commit details
  3. Copy the full SHA
    e501d86 View commit details
  4. Copy the full SHA
    bc5996a View commit details
  5. feat: Fix excludeAfterRemap functionality.

    Previously excludeAfterRemap caused filtering to happen before remapping
    to original source filenames.  This caused the filtering to be
    completely ineffective.  Fix the order, add a test to verify
    functionality.
    coreyfarrell committed Mar 7, 2019
    Copy the full SHA
    36bcc0b View commit details
  6. Copy the full SHA
    0fc217e View commit details

Commits on Mar 9, 2019

  1. Copy the full SHA
    b25492a View commit details

Commits on Mar 11, 2019

  1. Copy the full SHA
    3b203c7 View commit details

Commits on Mar 12, 2019

  1. Copy the full SHA
    d6db551 View commit details
  2. Copy the full SHA
    d3d95ff View commit details
  3. Copy the full SHA
    d8f28e9 View commit details

Commits on Mar 13, 2019

  1. Copy the full SHA
    364eb33 View commit details

Commits on Mar 17, 2019

  1. feat: add --build-process-tree feature (#1028)

    This allows a user to build the processinfo temp files, without actually
    dumping the process tree to stdout.
    
    The goal is to use this in node-tap to see which processes covered which
    files, so we know which tests to re-run on changes to the source files.
    isaacs authored and coreyfarrell committed Mar 17, 2019
    Copy the full SHA
    64571d3 View commit details

Commits on Mar 18, 2019

  1. feat: Pass extension to test-exclude, use TestExclude.globSync. (#1026

    )
    
    BREAKING CHANGE: The logic involving include/exclude processing has
    changed.  Results should be verified to ensure all desired sources have
    coverage data.
    coreyfarrell authored Mar 18, 2019
    Copy the full SHA
    aae5a59 View commit details
  2. feat: Rename plugins option to parser-plugins. (#1031)

    The original option name created confusion about what was expected.
    This helps identify that babel parser plugins are expected, not babel
    transform plugins.
    
    BREAKING CHANGE: The `plugins` option has been renamed to
    `parser-plugins`.
    
    Fixes #986
    coreyfarrell authored Mar 18, 2019
    Copy the full SHA
    2867538 View commit details
  3. Copy the full SHA
    91e02c6 View commit details

Commits on Mar 19, 2019

  1. Copy the full SHA
    051d95a View commit details
  2. Copy the full SHA
    1f6c3d4 View commit details

Commits on Mar 28, 2019

  1. test(instrument): should return unmodified source if no transform fou…

    …nd (#1036)
    
    * Test that the instrument command returns unmodified source if there is no transform found for a file extension.
    
    Currently this behaviour can only be reached when trying to instrument a single file.
    In the case of instrumenting a directory, files with an extension with no matching transform are filtered out before they can be instrumented.
    
    * Cleanup instrumentation code again with a focus on paths
    
    The main aim of this has been to clarify whether we're working with relative or absolute file paths, and removing unnecessary transformations.  Although I've made a few other 'small' changes here and there.
    
    Key changes:
    	* Created a new private method `NYC._transform`, common to `_maybeInstrumentSource` and `instrumentAllFiles`.
    	* Renamed the param in `walkAllFiles` forEach handler to `relFile` to explicitly state the file representation being used.
    	* Let the `addAllFiles` visitor function rely on `testExclude` to determine which files to instrument
    AndrewFinlay authored and JaKXz committed Mar 28, 2019
    Copy the full SHA
    5c1eb38 View commit details

Commits on Apr 1, 2019

  1. Copy the full SHA
    3eb0e37 View commit details

Commits on Apr 2, 2019

  1. Copy the full SHA
    b7e16cd View commit details

Commits on Apr 3, 2019

  1. fix: make --all work for transpiled code (#1047)

    * cache source maps globally
    bcoe authored and coreyfarrell committed Apr 3, 2019
    Copy the full SHA
    18e04ba View commit details
  2. Copy the full SHA
    31817de View commit details

Commits on Apr 4, 2019

  1. feat: add include and exclude options to instrument command (#1007)

    BREAKING CHANGE: `nyc instrument` now honors `include` and `exclude`
    settings, potentially resulting in some files that were previously
    instrumented being ignored.
    AndrewFinlay authored and coreyfarrell committed Apr 4, 2019
    Copy the full SHA
    8da097e View commit details
  2. Copy the full SHA
    68d6333 View commit details

Commits on Apr 5, 2019

  1. Copy the full SHA
    997ed29 View commit details
  2. fix: Use a single instance of nyc for all actions of main command. (#…

    …1059)
    
    This shares the same instance of nyc for execution, checking coverage
    and reporting.
    coreyfarrell authored Apr 5, 2019
    Copy the full SHA
    b909575 View commit details
  3. Copy the full SHA
    16d4315 View commit details

Commits on Apr 6, 2019

  1. fix: set processinfo pid/ppid to actual numbers (#1057)

    As of Node.js v6, process.ppid is available, and a number.  So, there's
    no need to pass the parent PID through the environment, which casts it
    to a string.
    
    BREAKING CHANGE: this changes the data type of the pid/ppid fields in
    processinfo files
    isaacs authored and coreyfarrell committed Apr 6, 2019
    Copy the full SHA
    32f75b0 View commit details
  2. feat: add processinfo index, add externalId (#1055)

    If a NYC_PROCESSINFO_EXTERNAL_ID environment variable is set, then it is
    saved in the processinfo as `externalId`.
    
    Furthermore, when this file is generated, some additional helpful
    metadata is memoized to the processinfo json files, to minimize the cost
    of repeated generation.  (This isn't necessarily a breaking change, but
    it is an update to the de facto schema for those files.)
    
    As soon as possible, index generation and process tree display should be
    migrated out to a new 'istanbul-lib-processinfo' library.
    
    This opens the door to add features in the v14 release family to improve
    support for partial/resumed test runs and file watching.
    
    - When a process is run with --clean=false and a previously seen
      externalId, clear away all the coverage files in the set for that
      externalId.
    - When a file is changed, a test runner can use the index to determine
      which tests (by externalId) ought to be re-run.
    - Adds a NYC_PROCESS_ID to environment
    - Adds `parent` to processInfo object, a uuid referring to parent.
    - Rebase onto processinfo-numeric-pids branch
    - Avoid re-writing the processinfo/{uuid}.json files
    - Update process tree output to rely on process index instead of
      duplicating effort.
    
    BREAKING CHANGE: This adds a file named 'index.json' to the
    .nyc_output/processinfo directory, which has a different format from the
    other files in this dir.
    isaacs authored and coreyfarrell committed Apr 6, 2019
    Copy the full SHA
    8dcf180 View commit details
  3. feat: Add support for --exclude-node-modules to subcommands. (#1053)

    This adds support for the `--exclude-node-modules` option/setting to
    instrument, check-coverage and report sub-commands.
    
    Add testing to verify that `--exclude-node-modules=false` is honored for
    all commands.
    coreyfarrell authored Apr 6, 2019
    Copy the full SHA
    e597c46 View commit details

Commits on Apr 9, 2019

  1. feat: always build the processinfo temp dir (#1061)

    Always build the processinfo data directory (with index) in
    ${tmpdir}/processinfo.  This more easily supports cases where the
    processinfo index may be useful for later analysis, or generating the
    process tree post hoc.
    isaacs authored and coreyfarrell committed Apr 9, 2019
    Copy the full SHA
    c213469 View commit details
  2. Copy the full SHA
    c88a852 View commit details
  3. feat: instrument --complete-copy implementation (#1056)

    With a few caveats:
    * This will dereference symlinks as it copies them, in some cases this could be a problem i.e. `node_modules/.bin`
    * This will not copy across empty directories
    AndrewFinlay authored and coreyfarrell committed Apr 9, 2019
    Copy the full SHA
    2eb13c6 View commit details
  4. Copy the full SHA
    189bae8 View commit details
  5. Copy the full SHA
    d7a9d6a View commit details

Commits on Apr 15, 2019

  1. Copy the full SHA
    8cf8a89 View commit details
  2. chore(release): 14.0.0

    coreyfarrell committed Apr 15, 2019
    Copy the full SHA
    e21721a View commit details
Showing with 2,865 additions and 2,405 deletions.
  1. +11 −10 ISSUE_TEMPLATE → .github/ISSUE_TEMPLATE.md
  2. +1 −1 .gitignore
  3. +45 −2 CHANGELOG.md
  4. +127 −93 README.md
  5. +15 −30 bin/nyc.js
  6. +8 −10 bin/wrap.js
  7. +40 −18 build-self-coverage.js
  8. +0 −56 build-tests.js
  9. +34 −0 docs/setup-codecov.md
  10. +34 −0 docs/setup-coveralls.md
  11. +168 −142 index.js
  12. +26 −6 lib/commands/check-coverage.js
  13. +64 −24 lib/commands/instrument.js
  14. +1 −6 lib/commands/merge.js
  15. +26 −6 lib/commands/report.js
  16. +23 −9 lib/config-util.js
  17. +26 −4 lib/hash.js
  18. +2 −2 lib/instrumenters/istanbul.js
  19. +18 −24 lib/process.js
  20. +11 −12 lib/source-maps.js
  21. +788 −1,773 package-lock.json
  22. +25 −60 package.json
  23. +1 −1 {lib → }/self-coverage-helper.js
  24. +1 −1 test/fixtures/_generateReport.js
  25. +6 −0 test/fixtures/cli/.instrument-nycrc
  26. +9 −0 test/fixtures/cli/no-transform/half-covered.xjs
  27. +1 −0 test/fixtures/cli/nyc-config-js/ignore.js
  28. +11 −0 test/fixtures/cli/nyc-config-js/index.js
  29. +3 −0 test/fixtures/cli/nyc-config-js/nyc.config.js
  30. +9 −0 test/fixtures/cli/nyc-config-js/nycrc-config.js
  31. +5 −0 test/fixtures/cli/nyc-config-js/package.json
  32. +1 −0 test/fixtures/cli/subdir/.gitignore
  33. +2 −0 test/fixtures/cli/subdir/input-dir/exclude-me/index.js
  34. +2 −0 test/fixtures/cli/subdir/input-dir/include-me/exclude-me.js
  35. +2 −0 test/fixtures/cli/subdir/input-dir/include-me/include-me.js
  36. +2 −0 test/fixtures/cli/subdir/input-dir/node_modules/index.js
  37. +2 −0 test/fixtures/exclude-node-modules/.gitignore
  38. 0 test/fixtures/exclude-node-modules/bin/do-nothing.js
  39. +1 −0 test/fixtures/exclude-node-modules/node_modules/@istanbuljs/fake-module-1/index.js
  40. +1 −0 test/fixtures/exclude-node-modules/node_modules/@istanbuljs/fake-module-2/index.js
  41. +1 −0 test/fixtures/exclude-node-modules/package.json
  42. +2 −2 test/fixtures/package.json
  43. +23 −0 test/lib/reset-state.js
  44. +533 −0 test/nyc-index.js
  45. +614 −52 test/{nyc-bin.js → nyc-integration.js}
  46. +0 −48 test/nyc.js
  47. +2 −1 test/process-args.js
  48. +95 −0 test/processinfo.js
  49. +20 −0 test/source-maps.js
  50. +23 −12 test/src/nyc-tap.js
21 changes: 11 additions & 10 deletions ISSUE_TEMPLATE → .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
<!--Please use the template provided below when reporting bugs:-->
## Link to bug demonstration repository.
## Link to bug demonstration repository
<!--
A demo repository will show the combination of module versions being used,
command-lines and configurations. NYC is very complex, it is difficult or
even impossible to triage most bugs without this information.
If you cannot share a link to your repository (maybe it's private) then you must
create a basic `nyc-bug-demo` repository and link to that please.
create a basic `nyc-bug-demo` repository and link to that please [mandatory].
-->

## Expected Behavior

## Observed Behavior

## Forensic Information
### Troubleshooting steps
- [ ] still occurrring when I put `cache: false` in my nyc config

**Operating System:** the operating system you observed the issue on.
**Environment Information:** information about your project's environment, see instructions below:

1. run the following script:

sh -c 'node --version; npm --version; npm ls' > output.txt
## Environment Information
<!--
[mandatory] run the following script: npx envinfo@latest --preset nyc
-->
```
# paste the output here
2. share a gist with the contents of output.txt.
```
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -3,6 +3,6 @@ coverage
node_modules
test/build/
.self_coverage
*.covered.js
self-coverage/
*.swp
needs-transpile.js
47 changes: 45 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,13 +2,56 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

# [14.0.0](https://github.com/istanbuljs/nyc/compare/v13.3.0...v14.0.0) (2019-04-15)


### Bug Fixes

* Add `cwd` option to instrument command ([#1024](https://github.com/istanbuljs/nyc/issues/1024)) ([051d95a](https://github.com/istanbuljs/nyc/commit/051d95a))
* Add config values to hash salt ([#988](https://github.com/istanbuljs/nyc/issues/988)) ([7ac325d](https://github.com/istanbuljs/nyc/commit/7ac325d)), closes [#522](https://github.com/istanbuljs/nyc/issues/522)
* Exclude negated not working with '--all' switch ([#977](https://github.com/istanbuljs/nyc/issues/977)) ([91de23c](https://github.com/istanbuljs/nyc/commit/91de23c))
* Make --all work for transpiled code ([#1047](https://github.com/istanbuljs/nyc/issues/1047)) ([18e04ba](https://github.com/istanbuljs/nyc/commit/18e04ba))
* Resolve absolute paths in nyc instrument ([#1012](https://github.com/istanbuljs/nyc/issues/1012)) ([3cb1861](https://github.com/istanbuljs/nyc/commit/3cb1861)), closes [#1014](https://github.com/istanbuljs/nyc/issues/1014)
* Set processinfo pid/ppid to actual numbers ([#1057](https://github.com/istanbuljs/nyc/issues/1057)) ([32f75b0](https://github.com/istanbuljs/nyc/commit/32f75b0))
* Use a single instance of nyc for all actions of main command. ([#1059](https://github.com/istanbuljs/nyc/issues/1059)) ([b909575](https://github.com/istanbuljs/nyc/commit/b909575))


### Features

* Add `delete` option to instrument command ([#1005](https://github.com/istanbuljs/nyc/issues/1005)) ([d6db551](https://github.com/istanbuljs/nyc/commit/d6db551))
* Add `include` and `exclude` options to instrument command ([#1007](https://github.com/istanbuljs/nyc/issues/1007)) ([8da097e](https://github.com/istanbuljs/nyc/commit/8da097e))
* Add processinfo index, add externalId ([#1055](https://github.com/istanbuljs/nyc/issues/1055)) ([8dcf180](https://github.com/istanbuljs/nyc/commit/8dcf180))
* Add support for nyc.config.js ([#1019](https://github.com/istanbuljs/nyc/issues/1019)) ([3b203c7](https://github.com/istanbuljs/nyc/commit/3b203c7))
* Add support to exclude files on coverage report generation ([#982](https://github.com/istanbuljs/nyc/issues/982)) ([509c6aa](https://github.com/istanbuljs/nyc/commit/509c6aa))
* Add test-exclude args to check-coverage and report subcommands. ([0fc217e](https://github.com/istanbuljs/nyc/commit/0fc217e))
* Always build the processinfo temp dir ([#1061](https://github.com/istanbuljs/nyc/issues/1061)) ([c213469](https://github.com/istanbuljs/nyc/commit/c213469))
* Enable `es-modules` option for nyc instrument command ([#1006](https://github.com/istanbuljs/nyc/issues/1006)) ([596b120](https://github.com/istanbuljs/nyc/commit/596b120))
* Fix excludeAfterRemap functionality. ([36bcc0b](https://github.com/istanbuljs/nyc/commit/36bcc0b))
* Implement `nyc instrument --complete-copy` ([#1056](https://github.com/istanbuljs/nyc/issues/1056)) ([2eb13c6](https://github.com/istanbuljs/nyc/commit/2eb13c6))
* Remove bundling ([#1017](https://github.com/istanbuljs/nyc/issues/1017)) ([b25492a](https://github.com/istanbuljs/nyc/commit/b25492a))
* Support turning off node_modules default exclude via `exclude-node-modules` option ([#912](https://github.com/istanbuljs/nyc/issues/912)) ([b7e16cd](https://github.com/istanbuljs/nyc/commit/b7e16cd))
* Add support for `--exclude-node-modules` to subcommands. ([#1053](https://github.com/istanbuljs/nyc/issues/1053)) ([e597c46](https://github.com/istanbuljs/nyc/commit/e597c46))


### BREAKING CHANGES

* The `--exclude-after-remap` option is now functional and enabled by default. This causes the `include` and `exclude` lists to be processed after using source maps to determine the original filename of sources.
* Add a file named 'index.json' to the .nyc_output/processinfo directory, which has a different format from the other files in this dir.
* Change the data type of the pid/ppid fields in processinfo files
* `nyc instrument` now honors `include` and `exclude` settings, potentially resulting in some files that were previously instrumented being ignored.
* The `plugins` option has been renamed to `parser-plugins`.
* The logic involving include/exclude processing has changed. Results should be verified to ensure all desired sources have coverage data.
* `nyc instrument` now enables the `--es-module` option by default. This can cause failures to instrument scripts which violate `'use strict'` rules.



<a name="13.3.0"></a>
# [13.3.0](https://github.com/istanbuljs/nyc/compare/v13.2.0...v13.3.0) (2019-02-14)


### Bug Fixes

* update dependendencies due to vulnerabilities ([#992](https://github.com/istanbuljs/nyc/issues/992)) ([e8cc59b](https://github.com/istanbuljs/nyc/commit/e8cc59b)), closes [#991](https://github.com/istanbuljs/nyc/issues/991)
* update dependencies due to vulnerabilities ([#992](https://github.com/istanbuljs/nyc/issues/992)) ([e8cc59b](https://github.com/istanbuljs/nyc/commit/e8cc59b)), closes [#991](https://github.com/istanbuljs/nyc/issues/991)


### Features
@@ -53,7 +96,7 @@ All notable changes to this project will be documented in this file. See [standa

### Bug Fixes

* add flag to allow control of intrumenter esModules option, default to looser parsing ([#863](https://github.com/istanbuljs/nyc/issues/863)) ([6b6cd5e](https://github.com/istanbuljs/nyc/commit/6b6cd5e))
* add flag to allow control of instrumenter esModules option, default to looser parsing ([#863](https://github.com/istanbuljs/nyc/issues/863)) ([6b6cd5e](https://github.com/istanbuljs/nyc/commit/6b6cd5e))
* Enable es-modules by default. ([#889](https://github.com/istanbuljs/nyc/issues/889)) ([d0b76e2](https://github.com/istanbuljs/nyc/commit/d0b76e2)), closes [#796](https://github.com/istanbuljs/nyc/issues/796)
* Update caching-transform options. ([#873](https://github.com/istanbuljs/nyc/issues/873)) ([52b69ef](https://github.com/istanbuljs/nyc/commit/52b69ef))
* use uuid/v4 to generate unique identifiers. ([#883](https://github.com/istanbuljs/nyc/issues/883)) ([7483ed9](https://github.com/istanbuljs/nyc/commit/7483ed9))
220 changes: 127 additions & 93 deletions README.md
Original file line number Diff line number Diff line change
@@ -195,53 +195,139 @@ Install custom reporters as a development dependency and you can use the `--repo
nyc report --reporter=<custom-reporter-name>
```

## Excluding files
## Producing instrumented source

You can tell nyc to exclude specific files and directories by adding
an `nyc.exclude` array to your `package.json`. Each element of
the array is a glob pattern indicating which paths should be omitted.
The `nyc instrument` command can produce a set of instrumented source files.
These files are suitable for client side deployment in end to end testing.
You can create an instrumented version of your source code by running:

```bash
nyc instrument <input> [output]
```

`<input>` can be any file or directory within the project root directory.
The `[output]` directory is optional and can be located anywhere, if it is not set the instrumented code will be sent to `stdout`.
For example, `nyc instrument . ./output` will produce instrumented versions of any source files it finds in `.` and store them in `./output`.

Any existing output can be removed by specifying the `--delete` option.
Run `nyc instrument --help` to display a full list of available command options.

**Note:** `nyc instrument` will not copy the contents of a `.git` folder to the output directory.

## Setting the project root directory

nyc runs a lot of file system operations relative to the project root directory.
During startup nyc will look for the *default* project root directory.
The *default* project root directory is the first directory found that contains a `package.json` file when searching from the current working directory up.
If nyc fails to find a directory containing a `package.json` file, it will use the current working directory as the *default* project root directory.
You can change the project root directory with the `--cwd` option.

nyc uses the project root directory when:
* looking for source files to instrument
* creating globs for include and exclude rules during file selection
* loading custom require hooks from the `require` array

nyc may create artefact directories within the project root, such as:
* the report directory, `<project-root>/coverage`
* the cache directory, `<project-root>/node_modules/.cache/nyc`
* the temp directory, `<project-root>/.nyc_output`

## Selecting files for coverage

By default, nyc only collects coverage for source files that are visited during a test.
It does this by watching for files that are `require()`'d during the test.
When a file is `require()`'d, nyc creates and returns an instrumented version of the source, rather than the original.
Only source files that are visited during a test will appear in the coverage report and contribute to coverage statistics.

nyc will instrument all files if the `--all` flag is set or if running `nyc instrument`.
In this case all files will appear in the coverage report and contribute to coverage statistics.

nyc will only collect coverage for files that are located under `cwd`, and then only `*.js` files or files with extensions listed in the `extension` array.

You can reduce the set of instrumented files by adding `include` and `exclude` filter arrays to your config.
These allow you to shape the set of instrumented files by specifying glob patterns that can filter files from the default instrumented set.
The `exclude` array may also use exclude negated glob patterns, these are specified with a `!` prefix, and can restore sub-paths of excluded paths.

Globs are matched using [minimatch](https://www.npmjs.com/package/minimatch).

For example, the following config will exclude any files with the extension `.spec.js`,
and anything in the `build` directory:
We use the following process to remove files from consideration:
1. Limit the set of instrumented files to those files in paths listed in the `include` array.
2. Remove any files that are found in the `exclude` array.
3. Restore any exclude negated files that have been excluded in step 2.

### Using include and exclude arrays

If there are paths specified in the `include` array, then the set of instrumented files will be limited to eligible files found in those paths.
If the `include` array is left undefined all eligible files will be included, equivalent to setting `include: ['**']`.
Multiple `include` globs can be specified on the command line, each must follow a `--include`, `-n` switch.

If there are paths specified in the `exclude` array, then the set of instrumented files will not feature eligible files found in those paths.
You can also specify negated paths in the `exclude` array, by prefixing them with a `!`.
Negated paths can restore paths that have been already been excluded in the `exclude` array.
Multiple `exclude` globs can be specified on the command line, each must follow a `--exclude`, `-x` switch.

The `exclude` option has the following defaults settings:
```js
[
'coverage/**',
'packages/*/test/**',
'test/**',
'test{,-*}.js',
'**/*{.,-}test.js',
'**/__tests__/**',
'**/node_modules/**',
'**/babel.config.js'
]
```
These settings exclude `test` and `__tests__` directories as well as `test.js`, `*.test.js`, and `test-*.js` files.
Specifying your own exclude property completely replaces these defaults.

For example, the following config will collect coverage for every file in the `src` directory regardless of whether it is `require()`'d in a test.
It will also exclude any files with the extension `.spec.js`.

```json
{
"nyc": {
"all": true,
"include": [
"src/**/*.js"
],
"exclude": [
"**/*.spec.js",
"build"
"**/*.spec.js"
]
}
}
```
> Note: Since version 9.0 files under `node_modules/` are excluded by default.
add the exclude rule `!**/node_modules/` to stop this.

> Note: exclude defaults to `['coverage/**', 'test/**', 'test{,-*}.js', '**/*.test.js', '**/__tests__/**', '**/node_modules/**']`,
which would exclude `test`/`__tests__` directories as well as `test.js`, `*.test.js`,
and `test-*.js` files. Specifying your own exclude property overrides these defaults.
**Note:** Be wary of automatic OS glob expansion when specifying include/exclude globs with the CLI.
To prevent this, wrap each glob in single quotes.

### Including files within `node_modules`

## Including files
We always add `**/node_modules/**` to the exclude list, even if not specified in the config.
You can override this by setting `--exclude-node-modules=false`.

As an alternative to providing a list of files to `exclude`, you can provide
an `include` key with a list of globs to specify specific files that should be covered:
For example, in the following config, `"excludeNodeModules: false"` will prevent `node_modules` from being added to the exclude rules.
The set of include rules then restrict nyc to only consider instrumenting files found under the `lib/` and `node_modules/@my-org/` directories.
The exclude rules then prevent nyc instrumenting anything in a `test` folder and the file `node_modules/@my-org/something/unwanted.js`.

```json
{
"nyc": {
"include": ["**/build/umd/moment.js"]
"all": true,
"include": [
"lib/**",
"node_modules/@my-org/**"
],
"exclude": [
"node_modules/@my-org/something/unwanted.js",
"**/test/**"
],
"excludeNodeModules": false
}
}
```

> `nyc` uses minimatch for glob expansions, you can read its documentation [here](https://www.npmjs.com/package/minimatch).
> Note: include defaults to `['**']`
> ### Use the `--all` flag to include files that have not been required in your tests.
## Require additional modules

The `--require` flag can be provided to `nyc` to indicate that additional
@@ -255,7 +341,7 @@ modules should be required in the subprocess collecting coverage:

## Configuring `nyc`

Any configuration options that can be set via the command line can also be specified in the `nyc` stanza of your package.json, or within a `.nycrc` (or `.nycrc.json`) file:
Any configuration options that can be set via the command line can also be specified in the `nyc` stanza of your package.json, or within a `.nycrc`, `.nycrc.json`, or `nyc.config.js` file:

**package.json:**

@@ -294,6 +380,21 @@ Any configuration options that can be set via the command line can also be speci
}
```

Configuration can also be provided by `nyc.config.js` if programmed logic is required:
```js
'use strict';
const {defaultExclude} = require('test-exclude');
const isWindows = require('is-windows');

let platformExclude = [
isWindows() ? 'lib/posix.js' : 'lib/win32.js'
];

module.exports = {
exclude: platformExclude.concat(defaultExclude)
};
```

### Publish, and reuse, your nyc configuration

nyc allows you to inherit other configurations using the key `extends`. As an example,
@@ -362,76 +463,9 @@ rather than having to ignore every instance of that method:
}
```

## Integrating with coveralls

[coveralls.io](https://coveralls.io) is a great tool for adding
coverage reports to your GitHub project. Here's how to get nyc
integrated with coveralls and travis-ci.org:

1. add the coveralls and nyc dependencies to your module:

```shell
npm install coveralls nyc --save-dev
```

2. update the scripts in your package.json to include these bins:

```json
{
"scripts": {
"test": "nyc mocha",
"coverage": "nyc report --reporter=text-lcov | coveralls"
}
}
```

3. For private repos, add the environment variable `COVERALLS_REPO_TOKEN` to travis.

4. add the following to your `.travis.yml`:

```yaml
after_success: npm run coverage
```
That's all there is to it!
> Note: by default coveralls.io adds comments to pull-requests on GitHub, this can feel intrusive. To disable this, click on your repo on coveralls.io and uncheck `LEAVE COMMENTS?`.

## Integrating with codecov

`nyc npm test && nyc report --reporter=text-lcov > coverage.lcov && codecov`

[codecov](https://codecov.io/) is a great tool for adding
coverage reports to your GitHub project, even viewing them inline on GitHub with a browser extension:

Here's how to get `nyc` integrated with codecov and travis-ci.org:

1. add the codecov and nyc dependencies to your module:

```shell
npm install codecov nyc --save-dev
```

2. update the scripts in your package.json to include these bins:

```json
{
"scripts": {
"test": "nyc tap ./test/*.js",
"coverage": "nyc report --reporter=text-lcov > coverage.lcov && codecov"
}
}
```

3. For private repos, add the environment variable `CODECOV_TOKEN` to travis.

4. add the following to your `.travis.yml`:

```yaml
after_success: npm run coverage
```
## [Integrating with coveralls](./docs/setup-coveralls.md)

That's all there is to it!
## [Integrating with codecov](./docs/setup-codecov.md)

## Integrating with TAP formatters

Loading