Skip to content

Commit

Permalink
feat: upgrade to Istanbul 2.0 API, introduce nyc bin
Browse files Browse the repository at this point in the history
  • Loading branch information
Benjamin Coe committed Dec 4, 2016
1 parent 50af37b commit 2808c54
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
coverage/
node_modules/
.DS_Store
.nyc_output
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,16 @@ browserifyBundle.transform(istanbul({
./node_modules/.bin/browserify -t [ browserify-istanbul --ignore "**/bower_components/**" ] test/test-*.js -o bundle.js
```

### Interacting With Coverage Reports

To load and manipulate coverage reports, the command line tool [nyc](https://www.npmjs.com/package/nyc) can be used:

1. output the the `__coverage__` object to `./.nyc_output/coverage.json`.
* this can be facilitated using a library like [mocha-phantomjs-istanbul](https://www.npmjs.com/package/mocha-phantomjs-istanbul).
2. execute nyc with a list of [reporters](https://github.com/istanbuljs/istanbul-reports/tree/master/lib).
* `nyc report --reporter=lcov --reporter=text-summary`.

See [istanbul.js.org](https://istanbul.js.org/) for more examples and documentation.

## License

Expand Down
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var through = require('through');
var minimatch = require('minimatch');
var objectAssign = require('object-assign');

var defaultIgnore = ['**/node_modules/**', '**/bower_components/**', '**/test/**', '**/tests/**', '**/*.json'];

Expand Down Expand Up @@ -29,7 +30,16 @@ function transform(options, file) {
if (shouldIgnoreFile(file, options))
return through();

var instrumenter = new (options.instrumenter || require('istanbul')).Instrumenter(options.instrumenterConfig || {});
var instrumenterConfig = objectAssign({}, {
autoWrap: true,
coverageVariable: '__coverage__',
embedSource: true,
noCompact: false,
preserveComments: true,
produceSourceMap: true
}, options.instrumenterConfig);

var instrumenter = (options.instrumenter || require('istanbul-lib-instrument')).createInstrumenter(instrumenterConfig);

var data = '';
return through(function(buf) {
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
},
"scripts": {
"lint": "eslint index.js test/*.js",
"test": "istanbul cover _mocha"
"pretest": "npm run lint",
"test": "nyc --reporter=text --reporter=lcov mocha"
},
"pre-commit": [
"lint",
Expand All @@ -30,16 +31,18 @@
},
"homepage": "https://github.com/devongovett/browserify-istanbul",
"dependencies": {
"istanbul-lib-instrument": "^1.3.0",
"minimatch": "^3.0.0",
"object-assign": "^4.1.0",
"through": "^2.3.8"
},
"devDependencies": {
"browserify": "^13.0.0",
"coveralls": "^2.11.8",
"eslint": "^2.2.0",
"eslint-plugin-mocha": "^2.0.0",
"istanbul": "^0.4.2",
"mocha": "^2.4.5",
"nyc": "^10.0.0",
"pre-commit": "^1.1.2"
}
}

0 comments on commit 2808c54

Please sign in to comment.