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: v14.0.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.1.0
Choose a head ref
  • 15 commits
  • 33 files changed
  • 5 contributors

Commits on Apr 16, 2019

  1. Copy the full SHA
    c4fcf5e View commit details
  2. Copy the full SHA
    ca37ffa View commit details

Commits on Apr 17, 2019

  1. Copy the full SHA
    0f745ca View commit details
  2. fix: Exit with code 1 when nyc doesn't know what to do. (#1070)

    When nyc is not told to do anything this is an error.  We already
    printed the help message to stderr, now we exit with code 1 to indicate
    that nyc exited without doing anything.
    
    Add a test to cover this edge case and verify that both `nyc` and `nyc
    --help` produce output as expected to stdout and stderr, exit with the
    proper code.
    coreyfarrell authored Apr 17, 2019
    Copy the full SHA
    21fb2c8 View commit details

Commits on Apr 18, 2019

  1. chore: Add test for nyc --no-clean. (#1071)

    Verify that running `nyc command1 && nyc --no-clean command2` causes
    results results to be merged.
    coreyfarrell authored Apr 18, 2019
    Copy the full SHA
    85c1eac View commit details
  2. Copy the full SHA
    ca84c42 View commit details

Commits on Apr 22, 2019

  1. docs: instrument docs update [skip ci] (#1063)

    Add documentation for `--complete-copy`, and describe how to instrument source JIT on an express server.
    
    Move instrument doc to `docs/instrument.md`
    AndrewFinlay authored and JaKXz committed Apr 22, 2019
    Copy the full SHA
    56591fa View commit details

Commits on Apr 24, 2019

  1. Copy the full SHA
    600c867 View commit details
  2. Copy the full SHA
    a7bc7ae View commit details
  3. chore: node.js 12 compatibility for object snapshot test. (#1084)

    node.js 12 changes the format of `util.inspect`, this causes snapshot
    mismatch.  Replace our one object snapshot with a JSON stringified array
    of `[name, value]` pairs representing the object.  Use an array sorted
    by names as JSON.stringify does not guarantee order of elements in an
    object.
    coreyfarrell authored Apr 24, 2019
    Copy the full SHA
    6fc109f View commit details
  4. feat: Add support for env.NYC_CONFIG_OVERRIDE (#1077)

    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.
    isaacs authored and coreyfarrell committed Apr 24, 2019
    Copy the full SHA
    132a074 View commit details
  5. Copy the full SHA
    3d9eaa4 View commit details
  6. Copy the full SHA
    1e39ae1 View commit details
  7. Copy the full SHA
    5cc05f4 View commit details
  8. chore(release): 14.1.0

    coreyfarrell committed Apr 24, 2019
    Copy the full SHA
    c5d90fa View commit details
3 changes: 0 additions & 3 deletions .babelrc

This file was deleted.

17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -2,6 +2,23 @@

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.1.0](https://github.com/istanbuljs/nyc/compare/v14.0.0...v14.1.0) (2019-04-24)


### Bug Fixes

* Do not crash when nyc is run inside itself. ([#1068](https://github.com/istanbuljs/nyc/issues/1068)) ([c4fcf5e](https://github.com/istanbuljs/nyc/commit/c4fcf5e)), closes [#1067](https://github.com/istanbuljs/nyc/issues/1067)
* Exit with code 1 when nyc doesn't know what to do. ([#1070](https://github.com/istanbuljs/nyc/issues/1070)) ([21fb2c8](https://github.com/istanbuljs/nyc/commit/21fb2c8))
* Purge source-map cache before reporting if cache is disabled. ([#1080](https://github.com/istanbuljs/nyc/issues/1080)) ([3d9eaa4](https://github.com/istanbuljs/nyc/commit/3d9eaa4))
* Use correct config property for parser plugins ([#1082](https://github.com/istanbuljs/nyc/issues/1082)) ([a7bc7ae](https://github.com/istanbuljs/nyc/commit/a7bc7ae))


### Features

* add support for yaml configuration file ([#1054](https://github.com/istanbuljs/nyc/issues/1054)) ([ca37ffa](https://github.com/istanbuljs/nyc/commit/ca37ffa))



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


29 changes: 10 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -195,24 +195,7 @@ Install custom reporters as a development dependency and you can use the `--repo
nyc report --reporter=<custom-reporter-name>
```

## Producing instrumented source

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.
## [Producing instrumented source](./docs/instrument.md)

## Setting the project root directory

@@ -341,7 +324,15 @@ 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`, `.nycrc.json`, or `nyc.config.js` 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 seperate configuration file - a variety of flavors are available:

| File name | File Association |
|-----------------|------------------|
| `.nycrc` | JSON |
| `.nycrc.json` | JSON |
| `.nycrc.yaml` | YAML |
| `.nycrc.yml` | YAML |
| `nyc.config.js` | CommonJS export |

**package.json:**

2 changes: 2 additions & 0 deletions bin/nyc.js
Original file line number Diff line number Diff line change
@@ -67,6 +67,7 @@ if ([

nyc.writeProcessIndex()

nyc.maybePurgeSourceMapCache()
if (argv.checkCoverage) {
nyc.checkCoverage({
lines: argv.lines,
@@ -85,5 +86,6 @@ if ([
})
} else {
// I don't have a clue what you're doing.
process.exitCode = 1
yargs.showHelp()
}
6 changes: 6 additions & 0 deletions bin/wrap.js
Original file line number Diff line number Diff line change
@@ -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()
41 changes: 41 additions & 0 deletions docs/instrument.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Producing instrumented source

The `nyc instrument` command can produce instrumented source files.
These files are suitable for client side deployment during end to end testing.
You can either pre-instrument your source, or write instrumented source to a stream.

Run `nyc instrument --help` to display a full list of available command options.

## Pre-instrumented source

You can create pre-instrumented 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 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`.

The `--delete` option will remove the existing output directory before instrumenting.

The `--complete-copy` option will copy all remaining files from the `input` directory to the `output` directory.
When using `--complete-copy` nyc will not copy the contents of a `.git` folder to the output directory.

**Note:** `--complete-copy` will dereference any symlinks during the copy process, this may stop scripts running properly from the output directory.

## Streaming instrumentation

`nyc instrument` will stream instrumented source directly to `stdout`, that can then be piped to another process.
You can use this behaviour to create a server that can instrument files on request.
The following example shows streaming instrumentation middleware capable of instrumenting files on request.

```javascript
app.use((req, res, next) => {
const myOptions = ""
const filename = myHelper.getFilename(req)
const nyc = cp.spawn(`nyc instrument ${myOptions} ${filename}`)
nyc.stdout.pipe(res)
})
```
23 changes: 13 additions & 10 deletions docs/setup-codecov.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,29 @@
# Integrating with codecov.io

> **tl;dr**:
> `nyc --reporter=lcov npm test && npx 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](https://docs.codecov.io/docs/browser-extension).

[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:
## Quick start

Here's how to get `nyc` integrated with codecov and travis-ci.org, assuming you have the `npx` executable (included with npm v5.2 and above):
Assuming your `npm test` does not run `nyc` and you have the `npx` executable (npm v5.2+), have your CI runner execute the following:
```shell
npx nyc --reporter=lcov npm test && npx codecov
```

1. add the codecov and nyc dependencies to your module:
## Without `npx` - TravisCI example using npm scripts

1. add the codecov and nyc dependencies:

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

2. update the scripts in your package.json to include these lines:
2. update the scripts in your package.json to include these lines (replace `mocha` with your test runner):

```json
{
"scripts": {
"test": "nyc --reporter=lcov mocha ./test/*.js",
"coverage": "npx codecov"
"test": "nyc --reporter=lcov mocha",
"coverage": "codecov"
}
}
```
Loading