How to use the hook function from istanbul
Find comprehensive JavaScript istanbul.hook code examples handpicked from public code repositorys.
GitHub: beckermarc/cf-abacus

135 136 137 138 139 140 141 142 143 144
// match our instrumentMatcher const sources = {}; const maps = []; const transformers = []; if (commander.istanbul) istanbul.hook.hookRequire( instrumentMatcher(commander.istanbulIncludes), transformer(sources, maps, transformers)); // Save the original process send method as it may be mocked by the tests
GitHub: SBoudrias/gulp-istanbul

86 87 88 89 90 91 92 93 94 95
plugin.hookRequire = function (options) { var fileMap = {}; istanbul.hook.unhookRequire(); istanbul.hook.hookRequire(function (path) { return !!fileMap[normalizePathSep(path)]; }, function (code, path) { return fileMap[normalizePathSep(path)]; }, options);
+ 19 other calls in file
151 152 153 154 155 156 157 158 159 160
var instrumenter = new istanbul.Instrumenter({coverageVariable: coverageVar}); var transformer = instrumenter.instrumentSync.bind(instrumenter); var hookOpts = {verbose: options.isVerbose}; istanbul.hook.hookRequire(matchFn, transformer, hookOpts); // Hook context to ensure that all requireJS modules get instrumented. // Hooking require in isolation does not appear to be sufficient. istanbul.hook.hookRunInThisContext(matchFn, transformer, hookOpts);
+ 7 other calls in file
2 3 4 5 6 7 8 9 10
var through = require('through2').obj; var path = require('path'); var istanbul = require('istanbul'); var gutil = require('gulp-util'); var _ = require('lodash'); var hook = istanbul.hook; var Report = istanbul.Report; var Collector = istanbul.Collector; var PluginError = gutil.PluginError;
GitHub: marcelerz/preceptor

56 57 58 59 60 61 62 63 64 65
// Prepare coverage instrumentation instrumenter = new istanbul.Instrumenter({ coverageVariable: coverageVar, preserveComments: true }); transformer = instrumenter.instrumentSync.bind(instrumenter); // Hook-up transformer for every new file loaded istanbul.hook.hookRequire(function (filePath) { var allowed = false; // Inclusion _.each(coverageIncludes, function (include) {
+ 5 other calls in file
18 19 20 21 22 23 24 25 26 27
} }); Object.defineProperty(exports, 'hook', { enumerable: true, get: function get() { return _istanbul.hook; } }); Object.defineProperty(exports, 'Report', { enumerable: true,
istanbul.Collector is the most popular function in istanbul (108 examples)