-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PR-URL: #10856 Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Michael Dawson <michael_dawson@ca.ibm.com>
- Loading branch information
1 parent
9c45758
commit bc9c381
Showing
5 changed files
with
123 additions
and
2 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
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,46 @@ | ||
'use strict'; | ||
const process = require('process'); | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const mkdirSync = fs.mkdirSync; | ||
const writeFileSync = fs.writeFileSync; | ||
|
||
var isWritingCoverage = false; | ||
function writeCoverage() { | ||
if (isWritingCoverage || !global.__coverage__) { | ||
return; | ||
} | ||
isWritingCoverage = true; | ||
|
||
const dirname = path.join(path.dirname(process.execPath), '.coverage'); | ||
const filename = `coverage-${process.pid}-${Date.now()}.json`; | ||
try { | ||
mkdirSync(dirname); | ||
} catch (err) { | ||
if (err.code !== 'EEXIST') { | ||
console.error(err); | ||
return; | ||
} | ||
} | ||
|
||
const target = path.join(dirname, filename); | ||
const coverageInfo = JSON.stringify(global.__coverage__); | ||
try { | ||
writeFileSync(target, coverageInfo); | ||
} catch (err) { | ||
console.error(err); | ||
} | ||
} | ||
|
||
function setup() { | ||
const reallyReallyExit = process.reallyExit; | ||
|
||
process.reallyExit = function(code) { | ||
writeCoverage(); | ||
reallyReallyExit(code); | ||
}; | ||
|
||
process.on('exit', writeCoverage); | ||
} | ||
|
||
exports.setup = setup; |
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