$
This commit is contained in:
44
node_modules/nyc/lib/instrumenters/istanbul.js
generated
vendored
Normal file
44
node_modules/nyc/lib/instrumenters/istanbul.js
generated
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict'
|
||||
|
||||
function InstrumenterIstanbul (options) {
|
||||
const { createInstrumenter } = require('istanbul-lib-instrument')
|
||||
const convertSourceMap = require('convert-source-map')
|
||||
|
||||
const instrumenter = createInstrumenter({
|
||||
autoWrap: true,
|
||||
coverageVariable: '__coverage__',
|
||||
embedSource: true,
|
||||
compact: options.compact,
|
||||
preserveComments: options.preserveComments,
|
||||
produceSourceMap: options.produceSourceMap,
|
||||
ignoreClassMethods: options.ignoreClassMethods,
|
||||
esModules: options.esModules,
|
||||
parserPlugins: options.parserPlugins
|
||||
})
|
||||
|
||||
return {
|
||||
instrumentSync (code, filename, { sourceMap, registerMap }) {
|
||||
var instrumented = instrumenter.instrumentSync(code, filename, sourceMap)
|
||||
if (instrumented !== code) {
|
||||
registerMap()
|
||||
}
|
||||
|
||||
// the instrumenter can optionally produce source maps,
|
||||
// this is useful for features like remapping stack-traces.
|
||||
if (options.produceSourceMap) {
|
||||
var lastSourceMap = instrumenter.lastSourceMap()
|
||||
/* istanbul ignore else */
|
||||
if (lastSourceMap) {
|
||||
instrumented += '\n' + convertSourceMap.fromObject(lastSourceMap).toComment()
|
||||
}
|
||||
}
|
||||
|
||||
return instrumented
|
||||
},
|
||||
lastFileCoverage () {
|
||||
return instrumenter.lastFileCoverage()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = InstrumenterIstanbul
|
22
node_modules/nyc/lib/instrumenters/noop.js
generated
vendored
Normal file
22
node_modules/nyc/lib/instrumenters/noop.js
generated
vendored
Normal file
@@ -0,0 +1,22 @@
|
||||
'use strict'
|
||||
|
||||
function NOOP () {
|
||||
const { readInitialCoverage } = require('istanbul-lib-instrument')
|
||||
|
||||
return {
|
||||
instrumentSync (code, filename) {
|
||||
const extracted = readInitialCoverage(code)
|
||||
if (extracted) {
|
||||
this.fileCoverage = extracted.coverageData
|
||||
} else {
|
||||
this.fileCoverage = null
|
||||
}
|
||||
return code
|
||||
},
|
||||
lastFileCoverage () {
|
||||
return this.fileCoverage
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = NOOP
|
Reference in New Issue
Block a user