aboutsummaryrefslogtreecommitdiffstats
path: root/vnfmarket/src/main/webapp/vnfmarket/node_modules/karma-coverage/lib/preprocessor.js
diff options
context:
space:
mode:
Diffstat (limited to 'vnfmarket/src/main/webapp/vnfmarket/node_modules/karma-coverage/lib/preprocessor.js')
-rw-r--r--vnfmarket/src/main/webapp/vnfmarket/node_modules/karma-coverage/lib/preprocessor.js73
1 files changed, 0 insertions, 73 deletions
diff --git a/vnfmarket/src/main/webapp/vnfmarket/node_modules/karma-coverage/lib/preprocessor.js b/vnfmarket/src/main/webapp/vnfmarket/node_modules/karma-coverage/lib/preprocessor.js
deleted file mode 100644
index 822a150c..00000000
--- a/vnfmarket/src/main/webapp/vnfmarket/node_modules/karma-coverage/lib/preprocessor.js
+++ /dev/null
@@ -1,73 +0,0 @@
-var istanbul = require('istanbul'),
- ibrik = require('ibrik'),
- minimatch = require('minimatch'),
- globalSourceCache = require('./sourceCache');
-
-var createCoveragePreprocessor = function(logger, basePath, reporters, coverageReporter) {
- var log = logger.create('preprocessor.coverage');
- var instrumenterOverrides = (coverageReporter && coverageReporter.instrumenter) || {};
- var instrumenters = {istanbul: istanbul, ibrik: ibrik};
- var sourceCache = globalSourceCache.getByBasePath(basePath);
-
- // if coverage reporter is not used, do not preprocess the files
- if (reporters.indexOf('coverage') === -1) {
- return function(content, _, done) {
- done(content);
- };
- }
-
- // check instrumenter override requests
- function checkInstrumenters() {
- var literal;
- for (var pattern in instrumenterOverrides) {
- literal = String(instrumenterOverrides[pattern]).toLowerCase();
- if (literal !== 'istanbul' && literal !== 'ibrik') {
- log.error('Unknown instrumenter: %s', literal);
- return false;
- }
- }
- return true;
- }
- if (!checkInstrumenters()) {
- return function(content, _, done) {
- return done(1);
- };
- }
-
- return function(content, file, done) {
- log.debug('Processing "%s".', file.originalPath);
-
- var jsPath = file.originalPath.replace(basePath + '/', './');
- var instrumenterLiteral = jsPath.match(/\.coffee$/) ? 'ibrik' : 'istanbul';
-
- for (var pattern in instrumenterOverrides) {
- if (minimatch(file.originalPath, pattern, {dot: true})) {
- instrumenterLiteral = String(instrumenterOverrides[pattern]).toLowerCase();
- }
- }
-
- var instrumenter = new instrumenters[instrumenterLiteral].Instrumenter();
-
- instrumenter.instrument(content, jsPath, function(err, instrumentedCode) {
- if (err) {
- log.error('%s\n at %s', err.message, file.originalPath);
- }
-
- if (instrumenterLiteral === 'ibrik') {
- file.path = file.path.replace(/\.coffee$/, '.js');
- }
-
- // remember the actual immediate instrumented JS for given original path
- sourceCache[jsPath] = content;
-
- done(instrumentedCode);
- });
- };
-};
-
-createCoveragePreprocessor.$inject = ['logger',
- 'config.basePath',
- 'config.reporters',
- 'config.coverageReporter'];
-
-module.exports = createCoveragePreprocessor;