wallet-core/node_modules/nyc/lib/self-coverage-helper.js
2017-05-28 00:40:43 +02:00

21 lines
565 B
JavaScript

/* global ___NYC_SELF_COVERAGE___ */
const path = require('path')
const fs = require('fs')
const mkdirp = require('mkdirp')
const onExit = require('signal-exit')
onExit(function () {
var coverage = global.___NYC_SELF_COVERAGE___
if (typeof ___NYC_SELF_COVERAGE___ === 'object') coverage = ___NYC_SELF_COVERAGE___
if (!coverage) return
var selfCoverageDir = path.join(__dirname, '../.self_coverage')
mkdirp.sync(selfCoverageDir)
fs.writeFileSync(
path.join(selfCoverageDir, process.pid + '.json'),
JSON.stringify(coverage),
'utf-8'
)
})