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: fe3311bd4770726c67e6eee1e39b15a3b616457b
Choose a base ref
...
head repository: istanbuljs/nyc
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: bebf4d68c6a2cb0c5fd66ba3513a8e68ad5a284f
Choose a head ref

Commits on May 10, 2019

  1. fix: Remove vestigial environment variables (#1078)

    This removes the NYC_ROOT_ID and NYC_INSTRUMENTER environment variables,
    which are no longer used or necessary.
    
    BREAKING CHANGE: Remove NYC_ROOT_ID and NYC_INSTRUMENTER environmental
    variables.
    
    BREAKING CHANGE: The `root` field has been removed from processinfo
    files.
    isaacs authored and coreyfarrell committed May 10, 2019
    Copy the full SHA
    cfd3da0 View commit details

Commits on May 12, 2019

  1. docs: Update README.md [skip ci] (#1114)

    Update all http links to https including community badge and doc site links.
    calvinf authored and JaKXz committed May 12, 2019
    Copy the full SHA
    a02c550 View commit details

Commits on May 13, 2019

  1. Copy the full SHA
    5464064 View commit details

Commits on May 18, 2019

  1. 3
    Copy the full SHA
    914b776 View commit details

Commits on Jun 20, 2019

  1. Copy the full SHA
    4bc9c14 View commit details

Commits on Jul 9, 2019

  1. chore: Remove test artefacts that ensure failure on subsequent tests (#…

    …1138)
    
    If the tests fail with a bad 'test/fixtures/cli/foo-cache', then subsequent tests will also fail unless the cache is cleaned.
    A failed test run also leaves a lot of files in 'test/temp-dir-nyc-integration' that are cleaned on success, but not before the start of the next run in case of failure.
    AndrewFinlay authored and coreyfarrell committed Jul 9, 2019
    Copy the full SHA
    421c5bd View commit details

Commits on Jul 12, 2019

  1. feat: Drop node.js 6, upgrade dependencies (#1134)

    BREAKING CHANGE: Node.js 8 is now required to run nyc
    coreyfarrell authored Jul 12, 2019
    Copy the full SHA
    00c3b34 View commit details

Commits on Jul 14, 2019

  1. Copy the full SHA
    7943413 View commit details

Commits on Jul 16, 2019

  1. chore: Suppress coverage for onExit callback (#1147)

    The callback is run but we're unable to record coverage for it.
    coreyfarrell authored Jul 16, 2019
    Copy the full SHA
    dcf4bbd View commit details

Commits on Jul 18, 2019

  1. Copy the full SHA
    e94e2e7 View commit details

Commits on Jul 26, 2019

  1. Copy the full SHA
    c358ce1 View commit details

Commits on Aug 1, 2019

  1. feat: Allow nyc instrument to instrument code in place (#1149)

    This change adds the `--in-place` switch to nyc instrument
    If `--in-place` is specified, the output directory will be set to equal the input directory for the instrument command.
    This has the effect of replacing any file in the input directory that should be instrumented, with its instrumented counterpart.
    The command will throw an error if the --delete option is specified.
    The only way to instrument in place is with the --in-place switch, setting the input and output directories to be the same will not work
    If `--in-place` is set the instrument command ignores any output directory specified with the command
    If `--in-place` is set the instrument command will disable the `--complete-copy` switch as it is unnecessary.
    AndrewFinlay authored and coreyfarrell committed Aug 1, 2019
    Copy the full SHA
    7783284 View commit details

Commits on Aug 2, 2019

  1. fix: Drop coverage produced by nyc --all for files that were tested (

    …#1155)
    
    * fix: Drop coverage produced by `nyc --all` for files that were tested
    
    Sometimes the coverage data produced by `nyc --all` is incompatible with
    the coverage data produced by actual test runs.  This is generally due
    to configuration error but results in inconsistent coverage reports or
    in some cases causes `nyc report` to crash.  The workaround is
    implemented in istanbul-lib-coverage to drop coverage data associated
    with `nyc --all` when coverage data from a test run is found.  This
    commit tags the coverage data when appropriate so the coverage merge
    logic knows what to do.
    
    Fixes #1113, #1124, #1148
    coreyfarrell authored Aug 2, 2019
    1
    Copy the full SHA
    fc1bbbf View commit details

Commits on Aug 23, 2019

  1. Copy the full SHA
    5c1b7a9 View commit details

Commits on Sep 9, 2019

  1. chore: Longer delay for stale bot (#1171)

    The default delay for the stale bot is too aggressive for our ability to
    keep up with issues.  This changes from 60 days to 365 days.
    coreyfarrell authored Sep 9, 2019
    Copy the full SHA
    f645762 View commit details

Commits on Sep 12, 2019

  1. chore: Update dependencies (#1174)

    In addition to bringing dependency ranges up to date this updates the
    package-lock.json to eliminate a `critical` warning from `npm audit`.
    
    I've skipped updating `standard` as this requires some code changes so
    it can be evaluated separately.
    coreyfarrell authored Sep 12, 2019
    Copy the full SHA
    811dd04 View commit details

Commits on Sep 13, 2019

  1. chore: Remove direct use of lodash by testing. (#1176)

    Only `_.filter` was used, replace with `Array#filter`.  Also delete
    unused fixtures which used lodash.
    coreyfarrell authored Sep 13, 2019
    Copy the full SHA
    318795c View commit details
  2. chore: Remove mocha compatibility layer and chai (#1178)

    * Split test/nyc-index.js and test/nyc-integration-old.js into separate
      test files using tap directly
    * Convert test/process-args.js to use tap directly
    coreyfarrell authored Sep 13, 2019
    Copy the full SHA
    03ba5b9 View commit details

Commits on Sep 24, 2019

  1. chore: Modernize lib/source-maps.js (#1175)

    * Convert to class
    * Prefer const over var
    * Use Object.entries()
    coreyfarrell authored Sep 24, 2019
    Copy the full SHA
    b59fc8f View commit details
  2. chore: Create npm-run-clean.js script (#1177)

    This allows use of globs without risk of shell interference, makes it
    easier to read the list of delete targets.
    coreyfarrell authored Sep 24, 2019
    Copy the full SHA
    0fc93d9 View commit details
  3. fix: Honor eager setting (false by default) (#1179)

    This delays loading of istanbul-lib-instrument until it is needed.
    coreyfarrell authored Sep 24, 2019
    Copy the full SHA
    c18fb0a View commit details

Commits on Sep 29, 2019

  1. Copy the full SHA
    1f535d7 View commit details

Commits on Oct 6, 2019

  1. Copy the full SHA
    b01a6d5 View commit details
  2. Copy the full SHA
    351106d View commit details
  3. Copy the full SHA
    80ad7da View commit details
  4. chore: Coverage for signal-exit handler. (#1190)

    This allows us to record coverage for all code called from the
    signal-exit handler.
    coreyfarrell authored Oct 6, 2019
    Copy the full SHA
    22a5ea0 View commit details
  5. fix: Avoid source-map module during signal-exit handler (#1191)

    Prior to this change child processes would call upon the source-map
    module to remap coverage during the `signal-exit` handler.  This was a
    blocker for updating `source-map` to 0.7.x which uses an async
    constructor method.
    
    Now we simply save the source-map with the raw coverage data for each
    file.  This allows the main nyc process to perform source-map remapping.
    The benefit is that the main nyc process can use async code.
    coreyfarrell authored Oct 6, 2019
    Copy the full SHA
    83eb629 View commit details
  6. Copy the full SHA
    04334e2 View commit details

Commits on Oct 7, 2019

  1. Copy the full SHA
    408c1cb View commit details
  2. feat: Add --use-spawn-wrap=true option (#1169)

    Completely bypass spawn-wrap unless overridden with this new option.
    coreyfarrell authored Oct 7, 2019
    Copy the full SHA
    df4de4d View commit details
  3. chore: Fix merge error (#1193)

    nyc.addAllFiles needs to be called after the `!argv.useSpawnWrap` branch
    performs the `require`'s and we need to await it.
    coreyfarrell authored Oct 7, 2019
    Copy the full SHA
    96b60b8 View commit details
  4. feat: Use @istanbuljs/schema for yargs setup (#1194)

    BREAKING CHANGE: The `flow` and `jsx` parser plugins are no longer
    enabled by default.
    coreyfarrell authored Oct 7, 2019
    Copy the full SHA
    fd40d49 View commit details
  5. Copy the full SHA
    2735ee2 View commit details
  6. Copy the full SHA
    bcbe1df View commit details
  7. Copy the full SHA
    cc77e13 View commit details
  8. chore: Tweak arguments for async coverage data readers (#1198)

    This allows istanbul-lib-processinfo to read coverage data files using
    only the `coverageFileLoad` function.
    coreyfarrell authored Oct 7, 2019
    Copy the full SHA
    0efc6d1 View commit details

Commits on Oct 9, 2019

  1. Copy the full SHA
    3726bbb View commit details

Commits on Oct 27, 2019

  1. docs: Fix URL to default excludes in README.md (#1214)

    Also remove some trailing white-space and correct a spelling mistake.
    Sintendo authored and coreyfarrell committed Oct 27, 2019
    Copy the full SHA
    f890360 View commit details

Commits on Nov 1, 2019

  1. Copy the full SHA
    8411a26 View commit details
  2. Copy the full SHA
    cf5e5d3 View commit details

Commits on Nov 3, 2019

  1. docs: npm home nyc goes to github master branch README (#1201)

    This causes confusion among users who think they're reading about the
    latest releaase.  It is better that we send users to istanbul.js.org for
    documentation.
    
    Issue #1200
    coreyfarrell authored Nov 3, 2019
    Copy the full SHA
    53c66b9 View commit details
  2. chore: Remove unused functions (#1218)

    A couple of sync functions were left behind for a previous version of
    istanbul-lib-processinfo.  These functions are no longer used so they
    are removed.
    coreyfarrell authored Nov 3, 2019
    Copy the full SHA
    ea94c7f View commit details

Commits on Nov 5, 2019

  1. Copy the full SHA
    7a02cb7 View commit details

Commits on Nov 7, 2019

  1. chore: Fix 404 in README.md. (#1220)

    default-exclude list has moved, missed a link in #1214.
    
    Fixes #1219
    coreyfarrell authored Nov 7, 2019
    Copy the full SHA
    8078a79 View commit details

Commits on Nov 16, 2019

  1. Copy the full SHA
    a1dee03 View commit details

Commits on Nov 18, 2019

  1. Copy the full SHA
    549c953 View commit details

Commits on Nov 19, 2019

  1. Copy the full SHA
    dfd629d View commit details
  2. chore: Remove cp-file module (#1230)

    This slightly reduces the amount of code nyc loads by using the core
    fs.copyFile function.  Clarify `package.json#engines` to show that
    node.js 8.9.0 (LTS) is the oldest supported release.
    coreyfarrell authored Nov 19, 2019
    Copy the full SHA
    7307626 View commit details
  3. Copy the full SHA
    28ed746 View commit details

Commits on Dec 7, 2019

  1. Copy the full SHA
    f3c9e6c View commit details
Showing with 7,827 additions and 6,670 deletions.
  1. +1 −1 .github/ISSUE_TEMPLATE.md
  2. +2 −0 .github/stale.yml
  3. +8 −0 .taprc
  4. +3 −2 .travis.yml
  5. +35 −1 CHANGELOG.md
  6. +19 −15 README.md
  7. +80 −53 bin/nyc.js
  8. +3 −26 bin/wrap.js
  9. +2 −0 build-self-coverage.js
  10. +4 −2 docs/instrument.md
  11. +154 −231 index.js
  12. +10 −59 lib/commands/check-coverage.js
  13. +74 −0 lib/commands/helpers.js
  14. +32 −100 lib/commands/instrument.js
  15. +18 −26 lib/commands/merge.js
  16. +11 −91 lib/commands/report.js
  17. +35 −267 lib/config-util.js
  18. +51 −0 lib/fs-promises.js
  19. +14 −18 lib/instrumenters/istanbul.js
  20. +4 −3 lib/instrumenters/noop.js
  21. +4 −2 lib/process-args.js
  22. +0 −92 lib/process.js
  23. +27 −0 lib/register-env.js
  24. +67 −43 lib/source-maps.js
  25. +28 −0 lib/wrap.js
  26. +19 −0 npm-run-clean.js
  27. +22 −0 nyc.config.js
  28. +4,448 −1,882 package-lock.json
  29. +37 −54 package.json
  30. +22 −11 self-coverage-helper.js
  31. +7 −7 tap-snapshots/test-config-override.js-TAP.test.js
  32. +16 −0 tap-snapshots/test-eager.js-TAP.test.js
  33. +17 −0 tap-snapshots/test-instrument.js-TAP.test.js
  34. +550 −169 tap-snapshots/test-nyc-integration.js-TAP.test.js
  35. +26 −0 tap-snapshots/test-tsc.js-TAP.test.js
  36. +127 −0 test/add-all-files.js
  37. +35 −0 test/cache.js
  38. +85 −0 test/config.js
  39. +39 −0 test/cwd.js
  40. +30 −0 test/eager.js
  41. +0 −71 test/fixtures/_generateReport.js
  42. +1 −1 test/fixtures/cli/external-instrumenter.js
  43. +5 −0 test/fixtures/cli/instrument-inplace/file1.js
  44. +5 −0 test/fixtures/cli/instrument-inplace/file2.js
  45. +1 −0 test/fixtures/cli/instrument-inplace/package.json
  46. +2 −0 test/fixtures/cli/selfspawn-fibonacci.js
  47. +4 −0 test/fixtures/conf-multiple-extensions/run.js
  48. +5 −0 test/fixtures/eager.js
  49. +9 −0 test/fixtures/hooks/run-in-context.js
  50. +4 −0 test/fixtures/nyc.config.js
  51. +3 −0 test/fixtures/parser-plugins/no-plugins.json
  52. +7 −0 test/fixtures/parser-plugins/package.json
  53. +2 −0 test/fixtures/parser-plugins/v8.js
  54. +0 −793 test/fixtures/report.js
  55. +1 −0 test/fixtures/tsc/.npmrc
  56. +16 −0 test/fixtures/tsc/mapping.js
  57. +1 −0 test/fixtures/tsc/mapping.js.map
  58. +8 −0 test/fixtures/tsc/mapping.ts
  59. +15 −0 test/fixtures/tsc/package.json
  60. +8 −0 test/fixtures/tsc/tsconfig.json
  61. +29 −0 test/helpers/env-check-config.js
  62. +5 −1 test/helpers/index.js
  63. +11 −0 test/helpers/parse-argv.js
  64. +16 −7 test/helpers/reset-state.js
  65. +15 −6 test/helpers/run-nyc.js
  66. +3 −0 test/helpers/source-map-support.js
  67. +2 −0 test/helpers/spawn.js
  68. +5 −7 test/helpers/temp-dir-setup.js
  69. +8 −6 test/helpers/test-failure.js
  70. +8 −6 test/helpers/test-success.js
  71. +355 −0 test/instrument.js
  72. +58 −0 test/issue-190.js
  73. +0 −533 test/nyc-index.js
  74. +0 −1,402 test/nyc-integration-old.js
  75. +536 −57 test/nyc-integration.js
  76. +29 −0 test/parser-plugins.js
  77. +64 −65 test/process-args.js
  78. +34 −43 test/processinfo.js
  79. +52 −0 test/report.js
  80. +76 −0 test/should-instrument.js
  81. +37 −0 test/source-map-support.js
  82. +0 −517 test/src/nyc-tap.js
  83. +81 −0 test/temp-dir.js
  84. +28 −0 test/tsc.js
  85. +112 −0 test/wrap.js
2 changes: 1 addition & 1 deletion .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ create a basic `nyc-bug-demo` repository and link to that please [mandatory].
## Observed Behavior

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

## Environment Information
<!--
2 changes: 2 additions & 0 deletions .github/stale.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
daysUntilStale: 365

exemptLabels:
- "Great First Contribution"
- pinned
8 changes: 8 additions & 0 deletions .taprc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"test-ignore": "^test/(helpers|src)/",
"coverage": false,
"jobs": 1,
"timeout": 360,
"bail": false,
"esm": false
}
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -7,16 +7,17 @@ node_js:
- "node"
- 10
- 8
- 6
matrix:
## An ENOMEM error occurs with 11.6.0 under Travis-CI for Windows.
## An ENOMEM error occurs with 10+ under Travis-CI for Windows.
## Disable until we can determine the cause.
# include:
# - os: windows
# node_js: "latest"
exclude:
- os: windows
node_js: "node"
- os: windows
node_js: 10
git:
depth:
1
36 changes: 35 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,41 @@
# Change Log
# Changelog

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.

## [15.0.0](https://github.com/istanbuljs/nyc/compare/v14.1.1...v15.0.0) (2019-12-20)


### ⚠ BREAKING CHANGES

* The `flow` and `jsx` parser plugins are no longer
enabled by default.
* Node.js 8 is now required to run nyc
* Remove NYC_ROOT_ID and NYC_INSTRUMENTER environmental
variables.
* The `root` field has been removed from processinfo
files.

### Features

* Add `--use-spawn-wrap=true` option ([#1169](https://github.com/istanbuljs/nyc/issues/1169)) ([df4de4d](https://github.com/istanbuljs/nyc/commit/df4de4d490f8cd32204fba66a810ed0444c26d0d))
* Add `.cjs`, `.mjs`, `.ts`, `.tsx`, `.jsx` to default extensions ([#1110](https://github.com/istanbuljs/nyc/issues/1110)) ([914b776](https://github.com/istanbuljs/nyc/commit/914b776215ad3ea54f0e46b4ba2904a8a9d4dfdd)), closes [#1103](https://github.com/istanbuljs/nyc/issues/1103)
* Allow `nyc instrument` to instrument code in place ([#1149](https://github.com/istanbuljs/nyc/issues/1149)) ([7783284](https://github.com/istanbuljs/nyc/commit/77832845b85134d21eca3a23c812c4f21f36713f))
* Drop node.js 6, upgrade dependencies ([#1134](https://github.com/istanbuljs/nyc/issues/1134)) ([00c3b34](https://github.com/istanbuljs/nyc/commit/00c3b3440a5b2ffe11b9c19ae4e08ad2f5b70e33))
* Filenames relative to project cwd in coverage reports ([#1212](https://github.com/istanbuljs/nyc/issues/1212)) ([5258e9f](https://github.com/istanbuljs/nyc/commit/5258e9fdb1d9e3d4abd4cc9768bc09cd8040a6be))
* Use @istanbuljs/schema for yargs setup ([#1194](https://github.com/istanbuljs/nyc/issues/1194)) ([fd40d49](https://github.com/istanbuljs/nyc/commit/fd40d49331665d936b86f30e9a873ba80071b770))
* Use istanbul-lib-processinfo ([#1145](https://github.com/istanbuljs/nyc/issues/1145)) ([7943413](https://github.com/istanbuljs/nyc/commit/7943413dc032f8f98a164fdde88d7344e817bb5e))
* Use source base name to prefix cache files ([#1144](https://github.com/istanbuljs/nyc/issues/1144)) ([5c1b7a9](https://github.com/istanbuljs/nyc/commit/5c1b7a9c43771f3439af44a1104e5426519e1123))


### Bug Fixes

* Avoid `source-map` module during `signal-exit` handler ([#1191](https://github.com/istanbuljs/nyc/issues/1191)) ([83eb629](https://github.com/istanbuljs/nyc/commit/83eb6294f9492bf98405ee9fdf6281c3bc199a3d))
* Better error handling for main execution, reporting ([#1229](https://github.com/istanbuljs/nyc/issues/1229)) ([dfd629d](https://github.com/istanbuljs/nyc/commit/dfd629d95716e6159aa7216c03e28a7fbbb161e7))
* Correct handling of source-maps for pre-instrumented files ([#1216](https://github.com/istanbuljs/nyc/issues/1216)) ([8411a26](https://github.com/istanbuljs/nyc/commit/8411a26c9e520c66251cc8044cde2c81f33f1c5f)), closes [#1208](https://github.com/istanbuljs/nyc/issues/1208)
* Drop coverage produced by `nyc --all` for files that were tested ([#1155](https://github.com/istanbuljs/nyc/issues/1155)) ([fc1bbbf](https://github.com/istanbuljs/nyc/commit/fc1bbbf490f6ab0272359ce10ceb4987d1716256)), closes [#1113](https://github.com/istanbuljs/nyc/issues/1113) [#1124](https://github.com/istanbuljs/nyc/issues/1124) [#1148](https://github.com/istanbuljs/nyc/issues/1148)
* Honor eager setting (false by default) ([#1179](https://github.com/istanbuljs/nyc/issues/1179)) ([c18fb0a](https://github.com/istanbuljs/nyc/commit/c18fb0a9a8eae5904298d87c62d9934243de8674))
* Remove vestigial environment variables ([#1078](https://github.com/istanbuljs/nyc/issues/1078)) ([cfd3da0](https://github.com/istanbuljs/nyc/commit/cfd3da05156b98952f03f7be2dd3d23ba328073f))

## [14.1.1](https://github.com/istanbuljs/nyc/compare/v14.1.0...v14.1.1) (2019-05-09)


34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -4,9 +4,9 @@
[![Coverage Status](https://coveralls.io/repos/istanbuljs/nyc/badge.svg?branch=)](https://coveralls.io/r/istanbuljs/nyc?branch=master)
[![NPM version](https://img.shields.io/npm/v/nyc.svg)](https://www.npmjs.com/package/nyc)
[![Conventional Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg)](https://conventionalcommits.org)
[![community slack](https://devtoolscommunity.herokuapp.com/badge.svg)](http://devtoolscommunity.herokuapp.com)
[![community slack](https://devtoolscommunity.herokuapp.com/badge.svg)](https://devtoolscommunity.herokuapp.com)

_Having problems? want to contribute? join our [community slack](http://devtoolscommunity.herokuapp.com)_.
_Having problems? want to contribute? join our [community slack](https://devtoolscommunity.herokuapp.com)_.

Istanbul's state of the art command line interface, with support for:

@@ -78,7 +78,7 @@ You can then add the specific configuration options you want that aren't in that

### Configuration files

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 seperate configuration file - a variety of flavors are available:
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 separate configuration file - a variety of flavors are available:

| File name | File Association |
|-----------------|------------------|
@@ -98,18 +98,18 @@ This table is a quick TLDR for the rest of this readme and there are more advanc
| ----------- | ----------- | ---- | ------- |
| `all` | Whether or not to instrument all files (not just the ones touched by your test suite) | `Boolean` | `false` |
| `check-coverage` | Check whether coverage is within thresholds, fail if not | `Boolean` | `false` |
| `extension` | List of extensions that nyc should attempt to handle in addition to `.js` | `Array<String>` | `['.js']` |
| `extension` | List of extensions that nyc should attempt to handle in addition to `.js` | `Array<String>` | `['.js', '.cjs', '.mjs', '.ts', '.tsx', '.jsx']` |
| `include` | See [selecting files for coverage] for more info | `Array<String>` | `['**']`|
| `exclude` | See [selecting files for coverage] for more info | `Array<String>` | [list](https://github.com/istanbuljs/istanbuljs/blob/master/packages/test-exclude/default-exclude.js) |
| `exclude` | See [selecting files for coverage] for more info | `Array<String>` | [list](https://github.com/istanbuljs/schema/blob/master/default-exclude.js) |
| `reporter` | [Coverage reporters to use](https://istanbul.js.org/docs/advanced/alternative-reporters/) | `Array<String>` | `['text']` |
| `report-dir` | Where to put the coverage report files | `String` | `./coverage` |
| `skip-full` | Don't show files with 100% statement, branch, and function coverage | `Boolean` | `false` |
| `temp-dir` | Directory to output raw coverage information to | `String` | `./.nyc_output` |

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

let platformExclude = [
@@ -142,13 +142,13 @@ module.exports = {

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.
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.
nyc will only collect coverage for files that are located under `cwd`, and then only 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.
@@ -172,7 +172,7 @@ You can also specify negated paths in the `exclude` array, by prefixing them wit
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 default `exclude` list is defined in the [test-exclude module](https://github.com/istanbuljs/istanbuljs/blob/master/packages/test-exclude/default-exclude.js).
The default `exclude` list is defined in the [@istanbuljs/schema module](https://github.com/istanbuljs/schema/blob/master/default-exclude.js).
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.
@@ -200,7 +200,7 @@ To prevent this, wrap each glob in single quotes.
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`.

For example, in the following config, `"excludeNodeModules: false"` will prevent `node_modules` from being added to the exclude rules.
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`.

@@ -371,13 +371,17 @@ Otherwise nyc's reports will exclude any files that source-maps remap to folders

Many testing frameworks (Mocha, Tape, Tap, etc.) can produce [TAP](https://en.wikipedia.org/wiki/Test_Anything_Protocol) output. [tap-nyc](https://github.com/MegaArman/tap-nyc) is a TAP formatter designed to look nice with nyc.

## More tutorials
## Tutorials and Advanced Documentation

You can find more tutorials at http://istanbul.js.org/docs/tutorials
See [more nyc tutorials](https://istanbul.js.org/docs/tutorials) and [advanced nyc documentation](https://istanbul.js.org/docs/advanced/).

## Other advanced features
Please feel free to [contribute documentation](https://github.com/istanbuljs/istanbuljs.github.io/tree/development/content) to help us improve.

Take a look at http://istanbul.js.org/docs/advanced/ and please feel free to [contribute documentation](https://github.com/istanbuljs/istanbuljs.github.io/tree/development/content).
## `nyc` for enterprise

Available as part of the Tidelift Subscription.

The maintainers of `nyc` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-nyc?utm_source=npm-nyc&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)

[`@babel/register`]: https://www.npmjs.com/package/@babel/register
[`babel-plugin-istanbul`]: https://github.com/istanbuljs/babel-plugin-istanbul
133 changes: 80 additions & 53 deletions bin/nyc.js
Original file line number Diff line number Diff line change
@@ -1,91 +1,118 @@
#!/usr/bin/env node
'use strict'

const configUtil = require('../lib/config-util')
const { cliWrapper, suppressEPIPE } = require('../lib/commands/helpers')
const foreground = require('foreground-child')
const resolveFrom = require('resolve-from')
const NYC = require('../index.js')
const processArgs = require('../lib/process-args')

const sw = require('spawn-wrap')
const wrapper = require.resolve('./wrap.js')

// parse configuration and command-line arguments;
// we keep these values in a few different forms,
// used in the various execution contexts of nyc:
// reporting, instrumenting subprocesses, etc.
const yargs = configUtil.buildYargs()
const instrumenterArgs = processArgs.hideInstrumenteeArgs()
const config = configUtil.loadConfig(yargs.parse(instrumenterArgs))
configUtil.addCommandsAndHelp(yargs)
const argv = yargs.config(config).parse(instrumenterArgs)

if ([
'check-coverage', 'report', 'instrument', 'merge'
].indexOf(argv._[0]) !== -1) {
// look in lib/commands for logic.
} else if (argv._.length) {

async function main () {
const { argv, childArgs, yargs } = await configUtil()

if (['check-coverage', 'report', 'instrument', 'merge'].includes(argv._[0])) {
// look in lib/commands for logic.
return
}

if (argv._.length === 0) {
// I don't have a clue what you're doing.
process.exitCode = 1
yargs.showHelp()
return
}

// if instrument is set to false,
// enable a noop instrumenter.
if (!argv.instrument) argv.instrumenter = './lib/instrumenters/noop'
else argv.instrumenter = './lib/instrumenters/istanbul'

var nyc = (new NYC(argv))
if (argv.clean) {
nyc.reset()
await nyc.reset()
} else {
nyc.createTempDirectory()
await nyc.createTempDirectory()
}
if (argv.all) nyc.addAllFiles()

var env = {
// Support running nyc as a user without HOME (e.g. linux 'nobody'),
// https://github.com/istanbuljs/nyc/issues/951
SPAWN_WRAP_SHIM_ROOT: process.env.SPAWN_WRAP_SHIM_ROOT || process.env.XDG_CACHE_HOME || require('os').homedir(),
const env = {
NYC_CONFIG: JSON.stringify(argv),
NYC_CWD: process.cwd(),
NYC_ROOT_ID: nyc.rootId,
NYC_INSTRUMENTER: argv.instrumenter
NYC_CWD: process.cwd()
}

/* istanbul ignore else */
if (argv['babel-cache'] === false) {
// babel's cache interferes with some configurations, so is
// disabled by default. opt in by setting babel-cache=true.
env.BABEL_DISABLE_CACHE = process.env.BABEL_DISABLE_CACHE = '1'
}

sw([wrapper], env)
if (!argv.useSpawnWrap) {
const requireModules = [
require.resolve('../lib/register-env.js'),
...nyc.require.map(mod => resolveFrom.silent(nyc.cwd, mod) || mod)
]
const preloadList = require('node-preload')
preloadList.push(
...requireModules,
require.resolve('../lib/wrap.js')
)

Object.assign(process.env, env)
requireModules.forEach(mod => {
require(mod)
})
}

if (argv.all) {
await nyc.addAllFiles()
}

if (argv.useSpawnWrap) {
const wrapper = require.resolve('./wrap.js')
// Support running nyc as a user without HOME (e.g. linux 'nobody'),
// https://github.com/istanbuljs/nyc/issues/951
env.SPAWN_WRAP_SHIM_ROOT = process.env.SPAWN_WRAP_SHIM_ROOT || process.env.XDG_CACHE_HOME || require('os').homedir()
const sw = require('spawn-wrap')

sw([wrapper], env)
}

// Both running the test script invocation and the check-coverage run may
// set process.exitCode. Keep track so that both children are run, but
// a non-zero exit codes in either one leads to an overall non-zero exit code.
process.exitCode = 0
foreground(processArgs.hideInstrumenterArgs(
// use the same argv descrption, but don't exit
// for flags like --help.
configUtil.buildYargs().parse(process.argv.slice(2))
), function (done) {
var mainChildExitCode = process.exitCode

nyc.writeProcessIndex()

nyc.maybePurgeSourceMapCache()
if (argv.checkCoverage) {
nyc.checkCoverage({
lines: argv.lines,
functions: argv.functions,
branches: argv.branches,
statements: argv.statements
}, argv['per-file'])
process.exitCode = process.exitCode || mainChildExitCode
}
foreground(childArgs, async () => {
const mainChildExitCode = process.exitCode

if (!argv.silent) {
nyc.report()
}
try {
await nyc.writeProcessIndex()

nyc.maybePurgeSourceMapCache()
if (argv.checkCoverage) {
await nyc.checkCoverage({
lines: argv.lines,
functions: argv.functions,
branches: argv.branches,
statements: argv.statements
}, argv['per-file']).catch(suppressEPIPE)
process.exitCode = process.exitCode || mainChildExitCode
}

return done()
if (!argv.silent) {
await nyc.report().catch(suppressEPIPE)
}
} catch (error) {
/* istanbul ignore next */
process.exitCode = process.exitCode || mainChildExitCode || 1
/* istanbul ignore next */
console.error(error.message)
}
})
} else {
// I don't have a clue what you're doing.
process.exitCode = 1
yargs.showHelp()
}

cliWrapper(main)()
29 changes: 3 additions & 26 deletions bin/wrap.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,4 @@
var sw = require('spawn-wrap')
var NYC = require('../index.js')
'use strict'

var config = {}
if (process.env.NYC_CONFIG) config = JSON.parse(process.env.NYC_CONFIG)
config.isChildProcess = true

config._processInfo = {
pid: process.pid,
ppid: process.ppid,
parent: process.env.NYC_PROCESS_ID || null,
root: process.env.NYC_ROOT_ID
}
if (process.env.NYC_PROCESSINFO_EXTERNAL_ID) {
config._processInfo.externalId = 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()
require('../lib/wrap')
require('spawn-wrap').runMain()
2 changes: 2 additions & 0 deletions build-self-coverage.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict'

const path = require('path')
const fs = require('fs')
const istanbul = require('istanbul-lib-instrument')
Loading