Skip to content

Commit

Permalink
docs: reference babel 7 in all places (#881)
Browse files Browse the repository at this point in the history
  • Loading branch information
coreyfarrell authored and bcoe committed Jul 5, 2018
1 parent 7483ed9 commit c325799
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 16 deletions.
24 changes: 12 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ _Having problems? want to contribute? join our [community slack](http://devtools
Istanbul's state of the art command line interface, with support for:

* applications that spawn subprocesses.
* ES2015 transforms, via [babel-plugin-istanbul](https://github.com/istanbuljs/babel-plugin-istanbul), or source-maps.
* ES2015 transforms, via [`babel-plugin-istanbul`], or source-maps.

## Instrumenting your code

Expand Down Expand Up @@ -62,10 +62,8 @@ stack traces for instrumented code will reflect their original lines.

### Support for custom require hooks (babel, typescript, etc.)

nyc supports custom require hooks like
[`babel-register`](http://babeljs.io/docs/usage/require/). nyc can
load the hooks for you, [using the `--require`
flag](#require-additional-modules).
nyc supports custom require hooks like [`@babel/register`]. nyc can load
the hooks for you, [using the `--require` flag](#require-additional-modules).

Source maps are used to map coverage information back to the appropriate lines
of the pre-transpiled code. You'll have to configure your custom require hook
Expand All @@ -75,8 +73,8 @@ the `sourceMaps` option to `inline`.
### Source-Map support for pre-instrumented codebases

If you opt to pre-instrument your source-code (rather than using a just-in-time
transpiler like [`babel-register`](http://babeljs.io/docs/usage/require/))
nyc supports both inline source-maps and `.map` files.
transpiler like [`@babel/register`]) nyc supports both inline source-maps and
`.map` files.

_Important: If you are using nyc with a project that pre-instruments its code,
run nyc with the configuration option `--exclude-after-remap` set to `false`.
Expand All @@ -85,15 +83,14 @@ covered under exclude rules._

## Use with `babel-plugin-istanbul` for Babel Support

We recommend using [`babel-plugin-istanbul`](https://github.com/istanbuljs/babel-plugin-istanbul) if your
project uses the babel tool chain:
We recommend using [`babel-plugin-istanbul`] if your project uses the babel tool chain:

1. enable the `babel-plugin-istanbul` plugin:

```json
{
"babel": {
"presets": ["env"],
"presets": ["@babel/env"],
"env": {
"test": {
"plugins": ["istanbul"]
Expand All @@ -114,7 +111,7 @@ project uses the babel tool chain:
{
"nyc": {
"require": [
"babel-register"
"@babel/register"
],
"sourceMap": false,
"instrument": false
Expand Down Expand Up @@ -251,7 +248,7 @@ an `include` key with a list of globs to specify specific files that should be c
The `--require` flag can be provided to `nyc` to indicate that additional
modules should be required in the subprocess collecting coverage:

`nyc --require babel-register --require babel-polyfill mocha`
`nyc --require @babel/register --require @babel/polyfill mocha`

## Caching

Expand Down Expand Up @@ -450,3 +447,6 @@ You can find more tutorials at http://istanbul.js.org/docs/tutorials
## Other advanced features
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).
[`@babel/register`]: https://www.npmjs.com/package/@babel/register
[`babel-plugin-istanbul`]: https://github.com/istanbuljs/babel-plugin-istanbul
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ NYC.prototype.getCoverageMapFromAllCoverageFiles = function (baseDirectory) {
map.merge(report)
}, baseDirectory)
// depending on whether source-code is pre-instrumented
// or instrumented using a JIT plugin like babel-require
// or instrumented using a JIT plugin like @babel/require
// you may opt to exclude files after applying
// source-map remapping logic.
if (this.config.excludeAfterRemap) {
Expand Down
2 changes: 1 addition & 1 deletion lib/commands/instrument.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ exports.builder = function (yargs) {
.option('require', {
alias: 'i',
default: [],
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill.'
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., @babel/register, @babel/polyfill.'
})
.option('extension', {
alias: 'e',
Expand Down
4 changes: 2 additions & 2 deletions lib/config-util.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ Config.buildYargs = function (cwd) {
.option('require', {
alias: 'i',
default: [],
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., babel-register, babel-polyfill',
describe: 'a list of additional modules that nyc should attempt to require in its subprocess, e.g., @babel/register, @babel/polyfill',
global: false
})
.option('eager', {
Expand Down Expand Up @@ -235,7 +235,7 @@ Config.buildYargs = function (cwd) {
})
.pkgConf('nyc', cwd)
.example('$0 npm test', 'instrument your tests with coverage')
.example('$0 --require babel-core/register npm test', 'instrument your tests with coverage and transpile with Babel')
.example('$0 --require @babel/register npm test', 'instrument your tests with coverage and transpile with Babel')
.example('$0 report --reporter=text-lcov', 'output lcov report after running your tests')
.epilog('visit https://git.io/vHysA for list of available reporters')
.boolean('h')
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,9 @@
"which": "^1.3.1",
"zero-fill": "^2.2.3"
},
"engines": {
"node": ">=6"
},
"repository": {
"type": "git",
"url": "git@github.com:istanbuljs/nyc.git"
Expand Down

0 comments on commit c325799

Please sign in to comment.