Skip to content

Commit

Permalink
Provide an option to skip path resolution
Browse files Browse the repository at this point in the history
  • Loading branch information
nimrod-becker committed Apr 20, 2016
1 parent 293cf78 commit 27be6aa
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Expand Up @@ -3,7 +3,7 @@
var through = require('through2').obj;
var path = require('path');
var checker = require('istanbul-threshold-checker');
// Make sure istanbul is `require`d after the istanbul-threshold-checker to use the istanbul version
// Make sure istanbul is `require`d after the istanbul-threshold-checker to use the istanbul version
// defined in this package.json instead of the one defined in istanbul-threshold-checker.
var istanbul = require('istanbul');
var gutil = require('gulp-util');
Expand All @@ -22,6 +22,7 @@ var plugin = module.exports = function (opts) {
instrumenter: istanbul.Instrumenter
});
opts.includeUntested = opts.includeUntested === true;
opts.resolveAbsolutePaths = opts.resolveAbsolutePaths === true;

var instrumenter = new opts.instrumenter(opts);

Expand All @@ -31,6 +32,10 @@ var plugin = module.exports = function (opts) {
return cb(new PluginError(PLUGIN_NAME, 'streams not supported'));
}

if (opts.resolveAbsolutePaths) {
file.path = path.resolve(file.path);
}

instrumenter.instrument(file.contents.toString(), file.path, function (err, code) {
if (err) {
return cb(new PluginError(
Expand All @@ -52,7 +57,7 @@ var plugin = module.exports = function (opts) {
if (covStubMatch !== null) {
var covStub = JSON.parse(covStubMatch[0]);
global[opts.coverageVariable] = global[opts.coverageVariable] || {};
global[opts.coverageVariable][path.resolve(file.path)] = covStub;
global[opts.coverageVariable][file.path] = covStub;
}
}

Expand Down

0 comments on commit 27be6aa

Please sign in to comment.