This repository has been archived by the owner on Aug 19, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
➕ remap coverage to original source if it was transpiled
- Loading branch information
deepsweet
committed
Sep 19, 2016
1 parent
756573f
commit b9f0299
Showing
8 changed files
with
88 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
class Hooks { | ||
constructor() { | ||
this.hooks = []; | ||
} | ||
|
||
add(hook) { | ||
this.hooks.push(hook); | ||
} | ||
|
||
clearAll() { | ||
this.hooks = this.hooks.filter((hook) => { | ||
hook(); | ||
|
||
return false; | ||
}); | ||
} | ||
} | ||
|
||
export default new Hooks(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { createSourceMapStore } from 'istanbul-lib-source-maps'; | ||
import { fromSource as getSourceMapFromSource } from 'convert-source-map'; | ||
|
||
const isLargeSource = true; | ||
|
||
class Remapper { | ||
constructor() { | ||
this.sourceMapStore = null; | ||
} | ||
|
||
createStore() { | ||
this.sourceMapStore = createSourceMapStore(); | ||
} | ||
|
||
addSource(file, source) { | ||
const sourceMap = getSourceMapFromSource(source, isLargeSource); | ||
|
||
if (sourceMap) { | ||
this.sourceMapStore.registerMap(file, sourceMap.toObject()); | ||
} | ||
} | ||
|
||
remapCoverageMap(coverageMap) { | ||
const transformedCoverage = this.sourceMapStore.transformCoverage(coverageMap); | ||
|
||
if (transformedCoverage) { | ||
return transformedCoverage.map; | ||
} | ||
} | ||
} | ||
|
||
export default new Remapper(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default '__start_istanbul__'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters