Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Export installCoverageExitHandler.

  • Loading branch information...
commit 29175bc081f8c63a0f5e29a827cbb27be9639c31 1 parent 5711091
@Kami Kami authored
Showing with 19 additions and 0 deletions.
  1. +1 −0  index.js
  2. +18 −0 lib/coverage.js
View
1  index.js
@@ -16,3 +16,4 @@
*/
exports.run = require('./lib/run.js').run;
+exports.installCoverageExitHandler = require('./lib/coverage').installExitHandler;
View
18 lib/coverage.js
@@ -193,6 +193,24 @@ function aggregateCoverage(files) {
return resultsObj;
}
+
+function installExitHandler() {
+ var pid = process.pid;
+ var coverageDirectory = process.env['COVERAGE_DIRECTORY'];
+ var coveragePath = path.join(coverageDirectory, pid + '.json');
+
+ function writeCoverage() {
+ if (typeof _$jscoverage === 'object') {
+ fs.writeFileSync(coveragePath, JSON.stringify(_$jscoverage), 'utf8');
+ }
+ }
+
+ if (coverageDirectory) {
+ process.on('exit', writeCoverage);
+ }
+}
+
exports.stringifyCoverage = stringifyCoverage;
exports.populateCoverage = populateCoverage;
exports.aggregateCoverage = aggregateCoverage;
+exports.installExitHandler = installExitHandler;
Please sign in to comment.
Something went wrong with that request. Please try again.