Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: initial support for source-maps (only supports one to one mapping) #19

Merged
merged 8 commits into from
Apr 29, 2019
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ converts from v8 coverage format to [istanbul's coverage format](https://github.

```js
const v8toIstanbul = require('v8-to-istanbul')
// create a script object from a source-file. the source file
// is loaded from disk and this is used to determine the original
// line count.
const script = v8toIstanbul('./path-to-instrumented-file.js')
// the path to the original source-file is required, as its contents are
// used during the conversion algorithm.
const converter = v8toIstanbul('./path-to-instrumented-file.js')
await converter.load() // this is required due to the async source-map dependency.
// provide an array of coverage information in v8 format.
script.applyCoverage([
converter.applyCoverage([
{
"functionName": "",
"ranges": [
Expand All @@ -31,7 +31,7 @@ script.applyCoverage([
])
// output coverage information in a form that can
// be consumed by Istanbul.
console.info(JSON.stringify(script.toIstanbul()))
console.info(JSON.stringify(converter.toIstanbul()))
```

## Testing
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const Script = require('./lib/script')
const V8ToIstanbul = require('./lib/v8-to-istanbul')

module.exports = function (path, wrapperLength) {
return new Script(path, wrapperLength)
return new V8ToIstanbul(path, wrapperLength)
}
10 changes: 5 additions & 5 deletions lib/branch.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,17 @@ module.exports = class CovBranch {
toIstanbul () {
const location = {
start: {
line: this.startLine.line,
column: this.startCol - this.startLine.startCol
line: this.startLine,
column: this.startCol
},
end: {
line: this.endLine.line,
column: this.endCol - this.endLine.startCol
line: this.endLine,
column: this.endCol
}
}
return {
type: 'branch',
line: this.line,
line: this.startLine,
loc: location,
locations: [Object.assign({}, location)]
}
Expand Down
10 changes: 5 additions & 5 deletions lib/function.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@ module.exports = class CovFunction {
toIstanbul () {
const loc = {
start: {
line: this.startLine.line,
column: this.startCol - this.startLine.startCol
line: this.startLine,
column: this.startCol
},
end: {
line: this.endLine.line,
column: this.endCol - this.endLine.startCol
line: this.endLine,
column: this.endCol
}
}
return {
name: this.name,
decl: loc,
loc: loc,
line: this.startLine.line
line: this.startLine
}
}
}
154 changes: 0 additions & 154 deletions lib/script.js

This file was deleted.

Loading