Skip to content

Commit

Permalink
fix(preprocessor): Change paths in windows to use backslash
Browse files Browse the repository at this point in the history
When istanbul creates a report combining json files from multiple
sources with different path separaters, all files are listed with the
full absolute path.

If path separators are consistent between json files, all files are
relative to a common base, and everything looks much nicer.

Closes #178
  • Loading branch information
tswaters committed Aug 26, 2015
1 parent c65074b commit b0eecbe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ function createCoveragePreprocessor (logger, helper, basePath, reporters, covera
return function (content, file, done) {
log.debug('Processing "%s".', file.originalPath)

var jsPath = require.resolve(file.originalPath)
// default instrumenters
var instrumenterLiteral = 'istanbul'

Expand Down Expand Up @@ -105,7 +106,7 @@ function createCoveragePreprocessor (logger, helper, basePath, reporters, covera
options = extend(options, {codeGenerationOptions: codeGenerationOptions})

var instrumenter = new InstrumenterConstructor(options)
instrumenter.instrument(content, file.originalPath, function (err, instrumentedCode) {
instrumenter.instrument(content, jsPath, function (err, instrumentedCode) {
if (err) {
log.error('%s\n at %s', err.message, file.originalPath)
}
Expand All @@ -120,7 +121,7 @@ function createCoveragePreprocessor (logger, helper, basePath, reporters, covera
}

// remember the actual immediate instrumented JS for given original path
sourceCache[file.originalPath] = content
sourceCache[jsPath] = content

if (includeAllSources) {
var coverageObjMatch = coverageObjRegex.exec(instrumentedCode)
Expand Down

0 comments on commit b0eecbe

Please sign in to comment.