From 27be6aaae82292c13548a1820c0f0732583e77f0 Mon Sep 17 00:00:00 2001 From: nimrod-becker Date: Wed, 20 Apr 2016 08:21:17 +0300 Subject: [PATCH 1/2] Provide an option to skip path resolution --- index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index c2cf412..ecc04a3 100644 --- a/index.js +++ b/index.js @@ -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'); @@ -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); @@ -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( @@ -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; } } From 5e79eb432c05cedbafd33f9a67280112b07ae5d6 Mon Sep 17 00:00:00 2001 From: nimrod-becker Date: Wed, 20 Apr 2016 10:22:08 +0300 Subject: [PATCH 2/2] Remove opts.resolveAbsolutePaths option, simply don't path.resolve --- index.js | 5 ----- 1 file changed, 5 deletions(-) diff --git a/index.js b/index.js index ecc04a3..0ad4e27 100644 --- a/index.js +++ b/index.js @@ -22,7 +22,6 @@ 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); @@ -32,10 +31,6 @@ 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(