v8-to-istanbul
Advanced tools
Comparing version 2.0.5 to 2.1.0
@@ -5,2 +5,11 @@ # Change Log | ||
# [2.1.0](https://github.com/bcoe/v8-to-istanbul/compare/v2.0.5...v2.1.0) (2019-04-21) | ||
### Features | ||
* store source so that it can be used by SourceMaps ([#18](https://github.com/bcoe/v8-to-istanbul/issues/18)) ([5afafd6](https://github.com/bcoe/v8-to-istanbul/commit/5afafd6)) | ||
## [2.0.5](https://github.com/bcoe/v8-to-istanbul/compare/v2.0.4...v2.0.5) (2019-04-18) | ||
@@ -7,0 +16,0 @@ |
@@ -17,6 +17,6 @@ const assert = require('assert') | ||
const path = parsePath(scriptPath) | ||
const source = fs.readFileSync(path, 'utf8') | ||
this.path = path | ||
this.source = fs.readFileSync(path, 'utf8') | ||
this.wrapperLength = wrapperLength === undefined ? cjsWrapperLength : wrapperLength | ||
const shebangLength = getShebangLength(source) | ||
const shebangLength = this._getShebangLength() | ||
this.wrapperLength -= shebangLength | ||
@@ -27,7 +27,7 @@ this.lines = [] | ||
this.eof = -1 | ||
this._buildLines(source, this.lines, shebangLength) | ||
this._buildLines(this.lines, shebangLength) | ||
} | ||
_buildLines (source, lines, shebangLength) { | ||
_buildLines (lines, shebangLength) { | ||
let position = 0 | ||
for (const [i, lineStr] of source.trim().split(/(?<=\r?\n)/u).entries()) { | ||
for (const [i, lineStr] of this.source.trim().split(/(?<=\r?\n)/u).entries()) { | ||
const matchedNewLineChar = lineStr.match(/\r?\n$/u) | ||
@@ -142,12 +142,11 @@ const newLineLength = matchedNewLineChar ? matchedNewLineChar[0].length : 0 | ||
} | ||
} | ||
function getShebangLength (source) { | ||
if (source.indexOf('#!') === 0) { | ||
const match = source.match(/(?<shebang>#!.*)/) | ||
if (match) { | ||
return match.groups.shebang.length | ||
_getShebangLength () { | ||
if (this.source.indexOf('#!') === 0) { | ||
const match = this.source.match(/(?<shebang>#!.*)/) | ||
if (match) { | ||
return match.groups.shebang.length | ||
} | ||
} else { | ||
return 0 | ||
} | ||
} else { | ||
return 0 | ||
} | ||
@@ -154,0 +153,0 @@ } |
{ | ||
"name": "v8-to-istanbul", | ||
"version": "2.0.5", | ||
"version": "2.1.0", | ||
"description": "convert from v8 coverage format to istanbul's format", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
40396