Using Gulp - SitePen/remap-istanbul GitHub Wiki

You can utilize this package as a gulp plugin.

Installation

Typically you will want Gulp and remap-istanbul installed as development dependencies for your project. To install Gulp and remap-istanbul you would run the following using NodeJS's package manager from the root of your project:

$ npm install gulp remap-istanbul --save-dev

Usage

When using with Gulp, the remap-istanbul plugin assumes that the coverage information will be piped to it via the virtual filesystem that is part of Gulp. So from an overall workflow perspective, you would need to invoke your test tooling and then provide the remap-istanbul Gulp task with the coverage information the is emitted. The examples below though demonstrate using Gulp to read in the file from the file system.

There are two main ways remap-istanbul can be used with Gulp. Just taking an Istanbul coverage file, remapping and outputting it would look like this:

var gulp = require('gulp');
var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');

gulp.task('remap-istanbul', function () {
	return gulp.src('coverage-final.json')
		.pipe(remapIstanbul())
		.pipe(gulp.dest('coverage-remapped.json'));
});

Another way is to utilize the the plugin is to have the plugin write out the Istanbul reports directly. This can be accomplished by passing a reports property in the options. For example, to have the JSON coverage report output in addition to the HTML coverage report, at task would look like this:

var gulp = require('gulp');
var remapIstanbul = require('remap-istanbul/lib/gulpRemapIstanbul');

gulp.task('remap-istanbul', function () {
	return gulp.src('coverage-final.json')
		.pipe(remapIstanbul({
			reports: {
				'json': 'coverage.json',
				'html': 'html-report'
			}
		}));
});

It is Gulp "anti-pattern" though to have tasks "write out" files directly, so you might want to consider better how to integrate to your specific workflow.