File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,21 @@ const isTravisCi = process.env.TRAVIS === 'true';
31
31
const codecovBashPath = process . platform === 'win32' ? join ( cwd , 'coverage' , uuidV4 ( ) ) : null ;
32
32
33
33
( async ( ) => {
34
+ // Remove this workaround when https://github.com/bcoe/c8/pull/83 is merged
35
+ try {
36
+ const patchPath = require . resolve ( './patch.txt' ) ;
37
+ const { readFile, unlink, writeFile} = require ( 'fs' ) ;
38
+
39
+ const originalScriptPath = require . resolve ( 'c8/lib/report.js' ) ;
40
+ const originalScript = await promisify ( readFile ) ( originalScriptPath , 'utf8' ) ;
41
+ await promisify ( writeFile ) ( originalScriptPath , originalScript . replace (
42
+ `script.applyCoverage(v8ScriptCov.functions)
43
+ map.merge(script.toIstanbul())` ,
44
+ await promisify ( readFile ) ( patchPath , 'utf8' )
45
+ ) ) ;
46
+ await promisify ( unlink ) ( patchPath ) ;
47
+ } catch { }
48
+
34
49
if ( command === undefined ) {
35
50
require ( c8BinPath ) ;
36
51
return ;
Original file line number Diff line number Diff line change 10
10
"test" : " node . node . test.js"
11
11
},
12
12
"files" : [
13
- " index.js"
13
+ " index.js" ,
14
+ " patch.txt"
14
15
],
15
16
"bin" : {
16
17
"coverage" : " index.js"
Original file line number Diff line number Diff line change
1
+ if (v8ScriptCov.functions.every(({ functionName, ranges }) => {
2
+ if (!script.source.includes(functionName)) {
3
+ return false
4
+ }
5
+
6
+ for (const { endOffset } of ranges) {
7
+ if (endOffset > script.source.length) {
8
+ return false
9
+ }
10
+ }
11
+
12
+ return true
13
+ })) {
14
+ script.applyCoverage(v8ScriptCov.functions)
15
+ map.merge(script.toIstanbul())
16
+ }
You can’t perform that action at this time.
0 commit comments