@vitest/coverage-istanbul 5.0.0-rc.2 → 5.0.0-rc.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/provider.d.ts +3 -139
- package/dist/provider.js +10 -3419
- package/package.json +7 -15
package/dist/provider.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import { existsSync, promises } from 'node:fs';
|
|
2
|
-
import require$$1$1, { defaults } from '@istanbuljs/schema';
|
|
3
2
|
import { GenMapping, addMapping, toEncodedMap } from '@jridgewell/gen-mapping';
|
|
4
|
-
import * as traceMapping from '@jridgewell/trace-mapping';
|
|
5
3
|
import { eachMapping, TraceMap } from '@jridgewell/trace-mapping';
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import libReport from 'istanbul-lib-report';
|
|
11
|
-
import require$$0$5 from 'path';
|
|
12
|
-
import require$$0$4 from 'tty';
|
|
13
|
-
import require$$1$2 from 'util';
|
|
14
|
-
import reports from 'istanbul-reports';
|
|
4
|
+
import * as libCoverage from '@vitest/istanbul-lib-coverage';
|
|
5
|
+
import { createInstrumenter } from '@vitest/istanbul-lib-instrument';
|
|
6
|
+
import * as libReport from '@vitest/istanbul-lib-report';
|
|
7
|
+
import * as libSourceMaps from '@vitest/istanbul-lib-source-maps';
|
|
15
8
|
import { parseModule } from 'magicast';
|
|
16
9
|
import { createDebug } from 'obug';
|
|
17
10
|
import c from 'tinyrainbow';
|
|
@@ -21,3405 +14,7 @@ import { C as COVERAGE_STORE_KEY } from './constants-BCJfMgEg.js';
|
|
|
21
14
|
import 'node:crypto';
|
|
22
15
|
import 'node:fs/promises';
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
|
26
|
-
}
|
|
27
|
-
function getAugmentedNamespace(n) {
|
|
28
|
-
if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
|
|
29
|
-
var f = n.default;
|
|
30
|
-
if (typeof f == "function") {
|
|
31
|
-
var a = function a() {
|
|
32
|
-
var isInstance = false;
|
|
33
|
-
try {
|
|
34
|
-
isInstance = this instanceof a;
|
|
35
|
-
} catch (e) {}
|
|
36
|
-
if (isInstance) {
|
|
37
|
-
return Reflect.construct(f, arguments, this.constructor);
|
|
38
|
-
}
|
|
39
|
-
return f.apply(this, arguments);
|
|
40
|
-
};
|
|
41
|
-
a.prototype = f.prototype;
|
|
42
|
-
} else a = {};
|
|
43
|
-
Object.defineProperty(a, "__esModule", { value: true });
|
|
44
|
-
Object.keys(n).forEach(function(k) {
|
|
45
|
-
var d = Object.getOwnPropertyDescriptor(n, k);
|
|
46
|
-
Object.defineProperty(a, k, d.get ? d : {
|
|
47
|
-
enumerable: true,
|
|
48
|
-
get: function() {
|
|
49
|
-
return n[k];
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
return a;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
var require$$3 = /*@__PURE__*/getAugmentedNamespace(traceMapping);
|
|
57
|
-
|
|
58
|
-
var sourceCoverage;
|
|
59
|
-
var hasRequiredSourceCoverage;
|
|
60
|
-
|
|
61
|
-
function requireSourceCoverage () {
|
|
62
|
-
if (hasRequiredSourceCoverage) return sourceCoverage;
|
|
63
|
-
hasRequiredSourceCoverage = 1;
|
|
64
|
-
const { classes } = require$$0;
|
|
65
|
-
|
|
66
|
-
function cloneLocation(loc) {
|
|
67
|
-
return {
|
|
68
|
-
start: {
|
|
69
|
-
line: loc && loc.start.line,
|
|
70
|
-
column: loc && loc.start.column
|
|
71
|
-
},
|
|
72
|
-
end: {
|
|
73
|
-
line: loc && loc.end.line,
|
|
74
|
-
column: loc && loc.end.column
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* SourceCoverage provides mutation methods to manipulate the structure of
|
|
80
|
-
* a file coverage object. Used by the instrumenter to create a full coverage
|
|
81
|
-
* object for a file incrementally.
|
|
82
|
-
*
|
|
83
|
-
* @private
|
|
84
|
-
* @param pathOrObj {String|Object} - see the argument for {@link FileCoverage}
|
|
85
|
-
* @extends FileCoverage
|
|
86
|
-
* @constructor
|
|
87
|
-
*/
|
|
88
|
-
class SourceCoverage extends classes.FileCoverage {
|
|
89
|
-
constructor(pathOrObj) {
|
|
90
|
-
super(pathOrObj);
|
|
91
|
-
this.meta = {
|
|
92
|
-
last: {
|
|
93
|
-
s: 0,
|
|
94
|
-
f: 0,
|
|
95
|
-
b: 0
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
newStatement(loc) {
|
|
101
|
-
const s = this.meta.last.s;
|
|
102
|
-
this.data.statementMap[s] = cloneLocation(loc);
|
|
103
|
-
this.data.s[s] = 0;
|
|
104
|
-
this.meta.last.s += 1;
|
|
105
|
-
return s;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
newFunction(name, decl, loc) {
|
|
109
|
-
const f = this.meta.last.f;
|
|
110
|
-
name = name || '(anonymous_' + f + ')';
|
|
111
|
-
this.data.fnMap[f] = {
|
|
112
|
-
name,
|
|
113
|
-
decl: cloneLocation(decl),
|
|
114
|
-
loc: cloneLocation(loc),
|
|
115
|
-
// DEPRECATED: some legacy reports require this info.
|
|
116
|
-
line: loc && loc.start.line
|
|
117
|
-
};
|
|
118
|
-
this.data.f[f] = 0;
|
|
119
|
-
this.meta.last.f += 1;
|
|
120
|
-
return f;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
newBranch(type, loc, isReportLogic = false) {
|
|
124
|
-
const b = this.meta.last.b;
|
|
125
|
-
this.data.b[b] = [];
|
|
126
|
-
this.data.branchMap[b] = {
|
|
127
|
-
loc: cloneLocation(loc),
|
|
128
|
-
type,
|
|
129
|
-
locations: [],
|
|
130
|
-
// DEPRECATED: some legacy reports require this info.
|
|
131
|
-
line: loc && loc.start.line
|
|
132
|
-
};
|
|
133
|
-
this.meta.last.b += 1;
|
|
134
|
-
this.maybeNewBranchTrue(type, b, isReportLogic);
|
|
135
|
-
return b;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
maybeNewBranchTrue(type, name, isReportLogic) {
|
|
139
|
-
if (!isReportLogic) {
|
|
140
|
-
return;
|
|
141
|
-
}
|
|
142
|
-
if (type !== 'binary-expr') {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
this.data.bT = this.data.bT || {};
|
|
146
|
-
this.data.bT[name] = [];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
addBranchPath(name, location) {
|
|
150
|
-
const bMeta = this.data.branchMap[name];
|
|
151
|
-
const counts = this.data.b[name];
|
|
152
|
-
|
|
153
|
-
/* istanbul ignore if: paranoid check */
|
|
154
|
-
if (!bMeta) {
|
|
155
|
-
throw new Error('Invalid branch ' + name);
|
|
156
|
-
}
|
|
157
|
-
bMeta.locations.push(cloneLocation(location));
|
|
158
|
-
counts.push(0);
|
|
159
|
-
this.maybeAddBranchTrue(name);
|
|
160
|
-
return counts.length - 1;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
maybeAddBranchTrue(name) {
|
|
164
|
-
if (!this.data.bT) {
|
|
165
|
-
return;
|
|
166
|
-
}
|
|
167
|
-
const countsTrue = this.data.bT[name];
|
|
168
|
-
if (!countsTrue) {
|
|
169
|
-
return;
|
|
170
|
-
}
|
|
171
|
-
countsTrue.push(0);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Assigns an input source map to the coverage that can be used
|
|
176
|
-
* to remap the coverage output to the original source
|
|
177
|
-
* @param sourceMap {object} the source map
|
|
178
|
-
*/
|
|
179
|
-
inputSourceMap(sourceMap) {
|
|
180
|
-
this.data.inputSourceMap = sourceMap;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
freeze() {
|
|
184
|
-
// prune empty branches
|
|
185
|
-
const map = this.data.branchMap;
|
|
186
|
-
const branches = this.data.b;
|
|
187
|
-
const branchesT = this.data.bT || {};
|
|
188
|
-
Object.keys(map).forEach(b => {
|
|
189
|
-
if (map[b].locations.length === 0) {
|
|
190
|
-
delete map[b];
|
|
191
|
-
delete branches[b];
|
|
192
|
-
delete branchesT[b];
|
|
193
|
-
}
|
|
194
|
-
});
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
sourceCoverage = { SourceCoverage };
|
|
199
|
-
return sourceCoverage;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
var name = "istanbul-lib-instrument";
|
|
203
|
-
var require$$1 = {
|
|
204
|
-
name: name};
|
|
205
|
-
|
|
206
|
-
var constants;
|
|
207
|
-
var hasRequiredConstants;
|
|
208
|
-
|
|
209
|
-
function requireConstants () {
|
|
210
|
-
if (hasRequiredConstants) return constants;
|
|
211
|
-
hasRequiredConstants = 1;
|
|
212
|
-
const { createHash } = require$$0$1;
|
|
213
|
-
const { name } = require$$1;
|
|
214
|
-
// TODO: increment this version if there are schema changes
|
|
215
|
-
// that are not backwards compatible:
|
|
216
|
-
const VERSION = '4';
|
|
217
|
-
|
|
218
|
-
const SHA = 'sha1';
|
|
219
|
-
constants = {
|
|
220
|
-
SHA,
|
|
221
|
-
MAGIC_KEY: '_coverageSchema',
|
|
222
|
-
MAGIC_VALUE: createHash(SHA)
|
|
223
|
-
.update(name + '@' + VERSION)
|
|
224
|
-
.digest('hex')
|
|
225
|
-
};
|
|
226
|
-
return constants;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
var ignoredLines;
|
|
230
|
-
var hasRequiredIgnoredLines;
|
|
231
|
-
|
|
232
|
-
function requireIgnoredLines () {
|
|
233
|
-
if (hasRequiredIgnoredLines) return ignoredLines;
|
|
234
|
-
hasRequiredIgnoredLines = 1;
|
|
235
|
-
const IGNORE_LINES_PATTERN = /\s*istanbul\s+ignore\s+(start|stop)/;
|
|
236
|
-
const EOL_PATTERN = /\r?\n/g;
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* Parse ignore start/stop hints from **text file** based on regular expressions
|
|
240
|
-
* - Does not understand what a comment is in Javascript (or JSX, Vue, Svelte)
|
|
241
|
-
* - Parses source code (JS, TS, Vue, Svelte, anything) based on text search by
|
|
242
|
-
* matching for `/* istanbul ignore start *\/` pattern - not by looking for real comments
|
|
243
|
-
*
|
|
244
|
-
* ```js
|
|
245
|
-
* /* istanbul ignore start *\/
|
|
246
|
-
* <!-- /* istanbul ignore start *\/ -->
|
|
247
|
-
* <SomeFrameworkComment content="/* istanbul ignore start *\/">
|
|
248
|
-
* ```
|
|
249
|
-
*/
|
|
250
|
-
function getIgnoredLines(text) {
|
|
251
|
-
if (!text) {
|
|
252
|
-
return new Set();
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
const ranges = [];
|
|
256
|
-
let lineNumber = 0;
|
|
257
|
-
|
|
258
|
-
for (const line of text.split(EOL_PATTERN)) {
|
|
259
|
-
lineNumber++;
|
|
260
|
-
|
|
261
|
-
const match = line.match(IGNORE_LINES_PATTERN);
|
|
262
|
-
if (match) {
|
|
263
|
-
const type = match[1];
|
|
264
|
-
|
|
265
|
-
if (type === 'stop') {
|
|
266
|
-
const previous = ranges.at(-1);
|
|
267
|
-
|
|
268
|
-
// Ignore whole "ignore stop" if no previous start was found
|
|
269
|
-
if (previous && previous.stop === Infinity) {
|
|
270
|
-
previous.stop = lineNumber;
|
|
271
|
-
}
|
|
272
|
-
|
|
273
|
-
continue;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
ranges.push({ start: lineNumber, stop: Infinity });
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const ignoredLines = new Set();
|
|
281
|
-
|
|
282
|
-
for (const range of ranges) {
|
|
283
|
-
for (let line = range.start; line <= range.stop; line++) {
|
|
284
|
-
ignoredLines.add(line);
|
|
285
|
-
|
|
286
|
-
if (line >= lineNumber) {
|
|
287
|
-
break;
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
return ignoredLines;
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
ignoredLines = { getIgnoredLines };
|
|
296
|
-
return ignoredLines;
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
var visitor;
|
|
300
|
-
var hasRequiredVisitor;
|
|
301
|
-
|
|
302
|
-
function requireVisitor () {
|
|
303
|
-
if (hasRequiredVisitor) return visitor;
|
|
304
|
-
hasRequiredVisitor = 1;
|
|
305
|
-
const { readFileSync } = require$$0$2;
|
|
306
|
-
const { createHash } = require$$0$1;
|
|
307
|
-
const { template } = require$$0$3;
|
|
308
|
-
const {
|
|
309
|
-
originalPositionFor,
|
|
310
|
-
TraceMap,
|
|
311
|
-
GREATEST_LOWER_BOUND,
|
|
312
|
-
LEAST_UPPER_BOUND,
|
|
313
|
-
sourceContentFor
|
|
314
|
-
} = require$$3;
|
|
315
|
-
const { defaults } = require$$1$1;
|
|
316
|
-
const { SourceCoverage } = requireSourceCoverage();
|
|
317
|
-
const { SHA, MAGIC_KEY, MAGIC_VALUE } = requireConstants();
|
|
318
|
-
const { getIgnoredLines } = requireIgnoredLines();
|
|
319
|
-
|
|
320
|
-
// pattern for istanbul to ignore a section
|
|
321
|
-
const COMMENT_RE = /^\s*istanbul\s+ignore\s+(if|else|next)(?=\W|$)/;
|
|
322
|
-
// pattern for istanbul to ignore the whole file
|
|
323
|
-
const COMMENT_FILE_RE = /^\s*istanbul\s+ignore\s+(file)(?=\W|$)/;
|
|
324
|
-
// source map URL pattern
|
|
325
|
-
const SOURCE_MAP_RE = /[#@]\s*sourceMappingURL=(.*)\s*$/m;
|
|
326
|
-
|
|
327
|
-
// generate a variable name from hashing the supplied file path
|
|
328
|
-
function genVar(filename) {
|
|
329
|
-
const hash = createHash(SHA);
|
|
330
|
-
hash.update(filename);
|
|
331
|
-
return 'cov_' + parseInt(hash.digest('hex').substr(0, 12), 16).toString(36);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// VisitState holds the state of the visitor, provides helper functions
|
|
335
|
-
// and is the `this` for the individual coverage visitors.
|
|
336
|
-
class VisitState {
|
|
337
|
-
constructor(
|
|
338
|
-
types,
|
|
339
|
-
sourceFilePath,
|
|
340
|
-
inputSourceMap,
|
|
341
|
-
ignoreClassMethods = [],
|
|
342
|
-
reportLogic = false,
|
|
343
|
-
ignoreLines = false
|
|
344
|
-
) {
|
|
345
|
-
this.varName = genVar(sourceFilePath);
|
|
346
|
-
this.attrs = {};
|
|
347
|
-
this.nextIgnore = null;
|
|
348
|
-
this.cov = new SourceCoverage(sourceFilePath);
|
|
349
|
-
|
|
350
|
-
if (typeof inputSourceMap !== 'undefined') {
|
|
351
|
-
this.cov.inputSourceMap(inputSourceMap);
|
|
352
|
-
|
|
353
|
-
if (ignoreLines) {
|
|
354
|
-
this.traceMap = new TraceMap(inputSourceMap);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
this.ignoreClassMethods = ignoreClassMethods;
|
|
358
|
-
this.ignoredLines = new Map();
|
|
359
|
-
this.types = types;
|
|
360
|
-
this.sourceMappingURL = null;
|
|
361
|
-
this.reportLogic = reportLogic;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
// should we ignore the node? Yes, if specifically ignoring
|
|
365
|
-
// or if the node is generated.
|
|
366
|
-
shouldIgnore(path) {
|
|
367
|
-
if (this.nextIgnore || !path.node.loc) {
|
|
368
|
-
return true;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
if (!this.traceMap) {
|
|
372
|
-
return false;
|
|
373
|
-
}
|
|
374
|
-
|
|
375
|
-
// Anything that starts between the line ignore hints is ignored
|
|
376
|
-
const start = originalPositionTryBoth(
|
|
377
|
-
this.traceMap,
|
|
378
|
-
path.node.loc.start
|
|
379
|
-
);
|
|
380
|
-
|
|
381
|
-
// Generated code
|
|
382
|
-
if (start.line == null) {
|
|
383
|
-
return false;
|
|
384
|
-
}
|
|
385
|
-
|
|
386
|
-
const filename = start.source;
|
|
387
|
-
let ignoredLines = this.ignoredLines.get(filename);
|
|
388
|
-
|
|
389
|
-
if (!ignoredLines) {
|
|
390
|
-
const sources = sourceContentFor(this.traceMap, filename);
|
|
391
|
-
ignoredLines = getIgnoredLines(
|
|
392
|
-
sources || tryReadFileSync(filename)
|
|
393
|
-
);
|
|
394
|
-
|
|
395
|
-
this.ignoredLines.set(filename, ignoredLines);
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
if (ignoredLines.has(start.line)) {
|
|
399
|
-
return true;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
return false;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
// extract the ignore comment hint (next|if|else) or null
|
|
406
|
-
hintFor(node) {
|
|
407
|
-
let hint = null;
|
|
408
|
-
if (node.leadingComments) {
|
|
409
|
-
node.leadingComments.forEach(c => {
|
|
410
|
-
const v = (
|
|
411
|
-
c.value || /* istanbul ignore next: paranoid check */ ''
|
|
412
|
-
).trim();
|
|
413
|
-
const groups = v.match(COMMENT_RE);
|
|
414
|
-
if (groups) {
|
|
415
|
-
hint = groups[1];
|
|
416
|
-
}
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
return hint;
|
|
420
|
-
}
|
|
421
|
-
|
|
422
|
-
// extract a source map URL from comments and keep track of it
|
|
423
|
-
maybeAssignSourceMapURL(node) {
|
|
424
|
-
const extractURL = comments => {
|
|
425
|
-
if (!comments) {
|
|
426
|
-
return;
|
|
427
|
-
}
|
|
428
|
-
comments.forEach(c => {
|
|
429
|
-
const v = (
|
|
430
|
-
c.value || /* istanbul ignore next: paranoid check */ ''
|
|
431
|
-
).trim();
|
|
432
|
-
const groups = v.match(SOURCE_MAP_RE);
|
|
433
|
-
if (groups) {
|
|
434
|
-
this.sourceMappingURL = groups[1];
|
|
435
|
-
}
|
|
436
|
-
});
|
|
437
|
-
};
|
|
438
|
-
extractURL(node.leadingComments);
|
|
439
|
-
extractURL(node.trailingComments);
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
// for these expressions the statement counter needs to be hoisted, so
|
|
443
|
-
// function name inference can be preserved
|
|
444
|
-
counterNeedsHoisting(path) {
|
|
445
|
-
return (
|
|
446
|
-
path.isFunctionExpression() ||
|
|
447
|
-
path.isArrowFunctionExpression() ||
|
|
448
|
-
path.isClassExpression()
|
|
449
|
-
);
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
// all the generic stuff that needs to be done on enter for every node
|
|
453
|
-
onEnter(path) {
|
|
454
|
-
const n = path.node;
|
|
455
|
-
|
|
456
|
-
this.maybeAssignSourceMapURL(n);
|
|
457
|
-
|
|
458
|
-
// if already ignoring, nothing more to do
|
|
459
|
-
if (this.nextIgnore !== null) {
|
|
460
|
-
return;
|
|
461
|
-
}
|
|
462
|
-
// check hint to see if ignore should be turned on
|
|
463
|
-
const hint = this.hintFor(n);
|
|
464
|
-
if (hint === 'next') {
|
|
465
|
-
this.nextIgnore = n;
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
// else check custom node attribute set by a prior visitor
|
|
469
|
-
if (this.getAttr(path.node, 'skip-all') !== null) {
|
|
470
|
-
this.nextIgnore = n;
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// else check for ignored class methods
|
|
474
|
-
if (
|
|
475
|
-
path.isFunctionExpression() &&
|
|
476
|
-
this.ignoreClassMethods.some(
|
|
477
|
-
name => path.node.id && name === path.node.id.name
|
|
478
|
-
)
|
|
479
|
-
) {
|
|
480
|
-
this.nextIgnore = n;
|
|
481
|
-
return;
|
|
482
|
-
}
|
|
483
|
-
if (
|
|
484
|
-
path.isClassMethod() &&
|
|
485
|
-
this.ignoreClassMethods.some(name => name === path.node.key.name)
|
|
486
|
-
) {
|
|
487
|
-
this.nextIgnore = n;
|
|
488
|
-
return;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
// all the generic stuff on exit of a node,
|
|
493
|
-
// including resetting ignores and custom node attrs
|
|
494
|
-
onExit(path) {
|
|
495
|
-
// restore ignore status, if needed
|
|
496
|
-
if (path.node === this.nextIgnore) {
|
|
497
|
-
this.nextIgnore = null;
|
|
498
|
-
}
|
|
499
|
-
// nuke all attributes for the node
|
|
500
|
-
delete path.node.__cov__;
|
|
501
|
-
}
|
|
502
|
-
|
|
503
|
-
// set a node attribute for the supplied node
|
|
504
|
-
setAttr(node, name, value) {
|
|
505
|
-
node.__cov__ = node.__cov__ || {};
|
|
506
|
-
node.__cov__[name] = value;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
// retrieve a node attribute for the supplied node or null
|
|
510
|
-
getAttr(node, name) {
|
|
511
|
-
const c = node.__cov__;
|
|
512
|
-
if (!c) {
|
|
513
|
-
return null;
|
|
514
|
-
}
|
|
515
|
-
return c[name];
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
//
|
|
519
|
-
increase(type, id, index) {
|
|
520
|
-
const T = this.types;
|
|
521
|
-
const wrap =
|
|
522
|
-
index !== null
|
|
523
|
-
? // If `index` present, turn `x` into `x[index]`.
|
|
524
|
-
x => T.memberExpression(x, T.numericLiteral(index), true)
|
|
525
|
-
: x => x;
|
|
526
|
-
return T.updateExpression(
|
|
527
|
-
'++',
|
|
528
|
-
wrap(
|
|
529
|
-
T.memberExpression(
|
|
530
|
-
T.memberExpression(
|
|
531
|
-
T.callExpression(T.identifier(this.varName), []),
|
|
532
|
-
T.identifier(type)
|
|
533
|
-
),
|
|
534
|
-
T.numericLiteral(id),
|
|
535
|
-
true
|
|
536
|
-
)
|
|
537
|
-
)
|
|
538
|
-
);
|
|
539
|
-
}
|
|
540
|
-
|
|
541
|
-
// Reads the logic expression conditions and conditionally increments truthy counter.
|
|
542
|
-
increaseTrue(type, id, index, node) {
|
|
543
|
-
const T = this.types;
|
|
544
|
-
const tempName = `${this.varName}_temp`;
|
|
545
|
-
|
|
546
|
-
return T.sequenceExpression([
|
|
547
|
-
T.assignmentExpression(
|
|
548
|
-
'=',
|
|
549
|
-
T.memberExpression(
|
|
550
|
-
T.callExpression(T.identifier(this.varName), []),
|
|
551
|
-
T.identifier(tempName)
|
|
552
|
-
),
|
|
553
|
-
node // Only evaluates once.
|
|
554
|
-
),
|
|
555
|
-
T.parenthesizedExpression(
|
|
556
|
-
T.conditionalExpression(
|
|
557
|
-
this.validateTrueNonTrivial(T, tempName),
|
|
558
|
-
this.increase(type, id, index),
|
|
559
|
-
T.nullLiteral()
|
|
560
|
-
)
|
|
561
|
-
),
|
|
562
|
-
T.memberExpression(
|
|
563
|
-
T.callExpression(T.identifier(this.varName), []),
|
|
564
|
-
T.identifier(tempName)
|
|
565
|
-
)
|
|
566
|
-
]);
|
|
567
|
-
}
|
|
568
|
-
|
|
569
|
-
validateTrueNonTrivial(T, tempName) {
|
|
570
|
-
return T.logicalExpression(
|
|
571
|
-
'&&',
|
|
572
|
-
T.memberExpression(
|
|
573
|
-
T.callExpression(T.identifier(this.varName), []),
|
|
574
|
-
T.identifier(tempName)
|
|
575
|
-
),
|
|
576
|
-
T.logicalExpression(
|
|
577
|
-
'&&',
|
|
578
|
-
T.parenthesizedExpression(
|
|
579
|
-
T.logicalExpression(
|
|
580
|
-
'||',
|
|
581
|
-
T.unaryExpression(
|
|
582
|
-
'!',
|
|
583
|
-
T.callExpression(
|
|
584
|
-
T.memberExpression(
|
|
585
|
-
T.identifier('Array'),
|
|
586
|
-
T.identifier('isArray')
|
|
587
|
-
),
|
|
588
|
-
[
|
|
589
|
-
T.memberExpression(
|
|
590
|
-
T.callExpression(
|
|
591
|
-
T.identifier(this.varName),
|
|
592
|
-
[]
|
|
593
|
-
),
|
|
594
|
-
T.identifier(tempName)
|
|
595
|
-
)
|
|
596
|
-
]
|
|
597
|
-
)
|
|
598
|
-
),
|
|
599
|
-
T.memberExpression(
|
|
600
|
-
T.memberExpression(
|
|
601
|
-
T.callExpression(
|
|
602
|
-
T.identifier(this.varName),
|
|
603
|
-
[]
|
|
604
|
-
),
|
|
605
|
-
T.identifier(tempName)
|
|
606
|
-
),
|
|
607
|
-
T.identifier('length')
|
|
608
|
-
)
|
|
609
|
-
)
|
|
610
|
-
),
|
|
611
|
-
T.parenthesizedExpression(
|
|
612
|
-
T.logicalExpression(
|
|
613
|
-
'||',
|
|
614
|
-
T.binaryExpression(
|
|
615
|
-
'!==',
|
|
616
|
-
T.callExpression(
|
|
617
|
-
T.memberExpression(
|
|
618
|
-
T.identifier('Object'),
|
|
619
|
-
T.identifier('getPrototypeOf')
|
|
620
|
-
),
|
|
621
|
-
[
|
|
622
|
-
T.memberExpression(
|
|
623
|
-
T.callExpression(
|
|
624
|
-
T.identifier(this.varName),
|
|
625
|
-
[]
|
|
626
|
-
),
|
|
627
|
-
T.identifier(tempName)
|
|
628
|
-
)
|
|
629
|
-
]
|
|
630
|
-
),
|
|
631
|
-
T.memberExpression(
|
|
632
|
-
T.identifier('Object'),
|
|
633
|
-
T.identifier('prototype')
|
|
634
|
-
)
|
|
635
|
-
),
|
|
636
|
-
T.memberExpression(
|
|
637
|
-
T.callExpression(
|
|
638
|
-
T.memberExpression(
|
|
639
|
-
T.identifier('Object'),
|
|
640
|
-
T.identifier('values')
|
|
641
|
-
),
|
|
642
|
-
[
|
|
643
|
-
T.memberExpression(
|
|
644
|
-
T.callExpression(
|
|
645
|
-
T.identifier(this.varName),
|
|
646
|
-
[]
|
|
647
|
-
),
|
|
648
|
-
T.identifier(tempName)
|
|
649
|
-
)
|
|
650
|
-
]
|
|
651
|
-
),
|
|
652
|
-
T.identifier('length')
|
|
653
|
-
)
|
|
654
|
-
)
|
|
655
|
-
)
|
|
656
|
-
)
|
|
657
|
-
);
|
|
658
|
-
}
|
|
659
|
-
|
|
660
|
-
insertCounter(path, increment) {
|
|
661
|
-
const T = this.types;
|
|
662
|
-
if (path.isBlockStatement()) {
|
|
663
|
-
path.node.body.unshift(T.expressionStatement(increment));
|
|
664
|
-
} else if (path.isStatement()) {
|
|
665
|
-
path.insertBefore(T.expressionStatement(increment));
|
|
666
|
-
} else if (
|
|
667
|
-
this.counterNeedsHoisting(path) &&
|
|
668
|
-
T.isVariableDeclarator(path.parentPath)
|
|
669
|
-
) {
|
|
670
|
-
// make an attempt to hoist the statement counter, so that
|
|
671
|
-
// function names are maintained.
|
|
672
|
-
const parent = path.parentPath.parentPath;
|
|
673
|
-
if (parent && T.isExportNamedDeclaration(parent.parentPath)) {
|
|
674
|
-
parent.parentPath.insertBefore(
|
|
675
|
-
T.expressionStatement(increment)
|
|
676
|
-
);
|
|
677
|
-
} else if (
|
|
678
|
-
parent &&
|
|
679
|
-
(T.isProgram(parent.parentPath) ||
|
|
680
|
-
T.isBlockStatement(parent.parentPath))
|
|
681
|
-
) {
|
|
682
|
-
parent.insertBefore(T.expressionStatement(increment));
|
|
683
|
-
} else {
|
|
684
|
-
path.replaceWith(T.sequenceExpression([increment, path.node]));
|
|
685
|
-
}
|
|
686
|
-
} /* istanbul ignore else: not expected */ else if (
|
|
687
|
-
path.isExpression()
|
|
688
|
-
) {
|
|
689
|
-
path.replaceWith(T.sequenceExpression([increment, path.node]));
|
|
690
|
-
} else {
|
|
691
|
-
console.error(
|
|
692
|
-
'Unable to insert counter for node type:',
|
|
693
|
-
path.node.type
|
|
694
|
-
);
|
|
695
|
-
}
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
insertStatementCounter(path) {
|
|
699
|
-
/* istanbul ignore if: paranoid check */
|
|
700
|
-
if (!(path.node && path.node.loc)) {
|
|
701
|
-
return;
|
|
702
|
-
}
|
|
703
|
-
const index = this.cov.newStatement(path.node.loc);
|
|
704
|
-
const increment = this.increase('s', index, null);
|
|
705
|
-
this.insertCounter(path, increment);
|
|
706
|
-
}
|
|
707
|
-
|
|
708
|
-
insertFunctionCounter(path) {
|
|
709
|
-
const T = this.types;
|
|
710
|
-
/* istanbul ignore if: paranoid check */
|
|
711
|
-
if (!(path.node && path.node.loc)) {
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
const n = path.node;
|
|
715
|
-
|
|
716
|
-
let dloc = null;
|
|
717
|
-
// get location for declaration
|
|
718
|
-
switch (n.type) {
|
|
719
|
-
case 'FunctionDeclaration':
|
|
720
|
-
case 'FunctionExpression':
|
|
721
|
-
/* istanbul ignore else: paranoid check */
|
|
722
|
-
if (n.id) {
|
|
723
|
-
dloc = n.id.loc;
|
|
724
|
-
}
|
|
725
|
-
break;
|
|
726
|
-
}
|
|
727
|
-
if (!dloc) {
|
|
728
|
-
dloc = {
|
|
729
|
-
start: n.loc.start,
|
|
730
|
-
end: { line: n.loc.start.line, column: n.loc.start.column + 1 }
|
|
731
|
-
};
|
|
732
|
-
}
|
|
733
|
-
|
|
734
|
-
const name = path.node.id ? path.node.id.name : path.node.name;
|
|
735
|
-
const index = this.cov.newFunction(name, dloc, path.node.body.loc);
|
|
736
|
-
const increment = this.increase('f', index, null);
|
|
737
|
-
const body = path.get('body');
|
|
738
|
-
/* istanbul ignore else: not expected */
|
|
739
|
-
if (body.isBlockStatement()) {
|
|
740
|
-
body.node.body.unshift(T.expressionStatement(increment));
|
|
741
|
-
} else {
|
|
742
|
-
console.error(
|
|
743
|
-
'Unable to process function body node type:',
|
|
744
|
-
path.node.type
|
|
745
|
-
);
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
|
|
749
|
-
getBranchIncrement(branchName, loc) {
|
|
750
|
-
const index = this.cov.addBranchPath(branchName, loc);
|
|
751
|
-
return this.increase('b', branchName, index);
|
|
752
|
-
}
|
|
753
|
-
|
|
754
|
-
getBranchLogicIncrement(path, branchName, loc) {
|
|
755
|
-
const index = this.cov.addBranchPath(branchName, loc);
|
|
756
|
-
return [
|
|
757
|
-
this.increase('b', branchName, index),
|
|
758
|
-
this.increaseTrue('bT', branchName, index, path.node)
|
|
759
|
-
];
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
insertBranchCounter(path, branchName, loc) {
|
|
763
|
-
const increment = this.getBranchIncrement(
|
|
764
|
-
branchName,
|
|
765
|
-
loc || path.node.loc
|
|
766
|
-
);
|
|
767
|
-
this.insertCounter(path, increment);
|
|
768
|
-
}
|
|
769
|
-
|
|
770
|
-
findLeaves(node, accumulator, parent, property) {
|
|
771
|
-
if (!node) {
|
|
772
|
-
return;
|
|
773
|
-
}
|
|
774
|
-
if (node.type === 'LogicalExpression') {
|
|
775
|
-
const hint = this.hintFor(node);
|
|
776
|
-
if (hint !== 'next') {
|
|
777
|
-
this.findLeaves(node.left, accumulator, node, 'left');
|
|
778
|
-
this.findLeaves(node.right, accumulator, node, 'right');
|
|
779
|
-
}
|
|
780
|
-
} else {
|
|
781
|
-
accumulator.push({
|
|
782
|
-
node,
|
|
783
|
-
parent,
|
|
784
|
-
property
|
|
785
|
-
});
|
|
786
|
-
}
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
|
|
790
|
-
// generic function that takes a set of visitor methods and
|
|
791
|
-
// returns a visitor object with `enter` and `exit` properties,
|
|
792
|
-
// such that:
|
|
793
|
-
//
|
|
794
|
-
// * standard entry processing is done
|
|
795
|
-
// * the supplied visitors are called only when ignore is not in effect
|
|
796
|
-
// This relieves them from worrying about ignore states and generated nodes.
|
|
797
|
-
// * standard exit processing is done
|
|
798
|
-
//
|
|
799
|
-
function entries(...enter) {
|
|
800
|
-
// the enter function
|
|
801
|
-
const wrappedEntry = function(path, node) {
|
|
802
|
-
this.onEnter(path);
|
|
803
|
-
if (this.shouldIgnore(path)) {
|
|
804
|
-
return;
|
|
805
|
-
}
|
|
806
|
-
enter.forEach(e => {
|
|
807
|
-
e.call(this, path, node);
|
|
808
|
-
});
|
|
809
|
-
};
|
|
810
|
-
const exit = function(path, node) {
|
|
811
|
-
this.onExit(path, node);
|
|
812
|
-
};
|
|
813
|
-
return {
|
|
814
|
-
enter: wrappedEntry,
|
|
815
|
-
exit
|
|
816
|
-
};
|
|
817
|
-
}
|
|
818
|
-
|
|
819
|
-
function coverStatement(path) {
|
|
820
|
-
this.insertStatementCounter(path);
|
|
821
|
-
}
|
|
822
|
-
|
|
823
|
-
/* istanbul ignore next: no node.js support */
|
|
824
|
-
function coverAssignmentPattern(path) {
|
|
825
|
-
const n = path.node;
|
|
826
|
-
const b = this.cov.newBranch('default-arg', n.loc);
|
|
827
|
-
this.insertBranchCounter(path.get('right'), b);
|
|
828
|
-
}
|
|
829
|
-
|
|
830
|
-
function coverFunction(path) {
|
|
831
|
-
this.insertFunctionCounter(path);
|
|
832
|
-
}
|
|
833
|
-
|
|
834
|
-
function coverVariableDeclarator(path) {
|
|
835
|
-
this.insertStatementCounter(path.get('init'));
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
function coverClassPropDeclarator(path) {
|
|
839
|
-
this.insertStatementCounter(path.get('value'));
|
|
840
|
-
}
|
|
841
|
-
|
|
842
|
-
function makeBlock(path) {
|
|
843
|
-
const T = this.types;
|
|
844
|
-
if (!path.node) {
|
|
845
|
-
path.replaceWith(T.blockStatement([]));
|
|
846
|
-
}
|
|
847
|
-
if (!path.isBlockStatement()) {
|
|
848
|
-
path.replaceWith(T.blockStatement([path.node]));
|
|
849
|
-
path.node.loc = path.node.body[0].loc;
|
|
850
|
-
path.node.body[0].leadingComments = path.node.leadingComments;
|
|
851
|
-
path.node.leadingComments = undefined;
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
function blockProp(prop) {
|
|
856
|
-
return function(path) {
|
|
857
|
-
makeBlock.call(this, path.get(prop));
|
|
858
|
-
};
|
|
859
|
-
}
|
|
860
|
-
|
|
861
|
-
function makeParenthesizedExpressionForNonIdentifier(path) {
|
|
862
|
-
const T = this.types;
|
|
863
|
-
if (path.node && !path.isIdentifier()) {
|
|
864
|
-
path.replaceWith(T.parenthesizedExpression(path.node));
|
|
865
|
-
}
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
function parenthesizedExpressionProp(prop) {
|
|
869
|
-
return function(path) {
|
|
870
|
-
makeParenthesizedExpressionForNonIdentifier.call(this, path.get(prop));
|
|
871
|
-
};
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
function convertArrowExpression(path) {
|
|
875
|
-
const n = path.node;
|
|
876
|
-
const T = this.types;
|
|
877
|
-
if (!T.isBlockStatement(n.body)) {
|
|
878
|
-
const bloc = n.body.loc;
|
|
879
|
-
if (n.expression === true) {
|
|
880
|
-
n.expression = false;
|
|
881
|
-
}
|
|
882
|
-
n.body = T.blockStatement([T.returnStatement(n.body)]);
|
|
883
|
-
// restore body location
|
|
884
|
-
n.body.loc = bloc;
|
|
885
|
-
// set up the location for the return statement so it gets
|
|
886
|
-
// instrumented
|
|
887
|
-
n.body.body[0].loc = bloc;
|
|
888
|
-
}
|
|
889
|
-
}
|
|
890
|
-
|
|
891
|
-
function coverIfBranches(path) {
|
|
892
|
-
const n = path.node;
|
|
893
|
-
const hint = this.hintFor(n);
|
|
894
|
-
const ignoreIf = hint === 'if';
|
|
895
|
-
const ignoreElse = hint === 'else';
|
|
896
|
-
const branch = this.cov.newBranch('if', n.loc);
|
|
897
|
-
|
|
898
|
-
if (ignoreIf) {
|
|
899
|
-
this.setAttr(n.consequent, 'skip-all', true);
|
|
900
|
-
} else {
|
|
901
|
-
this.insertBranchCounter(path.get('consequent'), branch, n.loc);
|
|
902
|
-
}
|
|
903
|
-
if (ignoreElse) {
|
|
904
|
-
this.setAttr(n.alternate, 'skip-all', true);
|
|
905
|
-
} else {
|
|
906
|
-
this.insertBranchCounter(path.get('alternate'), branch);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
|
|
910
|
-
function createSwitchBranch(path) {
|
|
911
|
-
const b = this.cov.newBranch('switch', path.node.loc);
|
|
912
|
-
this.setAttr(path.node, 'branchName', b);
|
|
913
|
-
}
|
|
914
|
-
|
|
915
|
-
function coverSwitchCase(path) {
|
|
916
|
-
const T = this.types;
|
|
917
|
-
const b = this.getAttr(path.parentPath.node, 'branchName');
|
|
918
|
-
/* istanbul ignore if: paranoid check */
|
|
919
|
-
if (b === null) {
|
|
920
|
-
throw new Error('Unable to get switch branch name');
|
|
921
|
-
}
|
|
922
|
-
const increment = this.getBranchIncrement(b, path.node.loc);
|
|
923
|
-
path.node.consequent.unshift(T.expressionStatement(increment));
|
|
924
|
-
}
|
|
925
|
-
|
|
926
|
-
function coverTernary(path) {
|
|
927
|
-
const n = path.node;
|
|
928
|
-
const branch = this.cov.newBranch('cond-expr', path.node.loc);
|
|
929
|
-
const cHint = this.hintFor(n.consequent);
|
|
930
|
-
const aHint = this.hintFor(n.alternate);
|
|
931
|
-
|
|
932
|
-
if (cHint !== 'next') {
|
|
933
|
-
this.insertBranchCounter(path.get('consequent'), branch);
|
|
934
|
-
}
|
|
935
|
-
if (aHint !== 'next') {
|
|
936
|
-
this.insertBranchCounter(path.get('alternate'), branch);
|
|
937
|
-
}
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
function coverLogicalExpression(path) {
|
|
941
|
-
const T = this.types;
|
|
942
|
-
if (path.parentPath.node.type === 'LogicalExpression') {
|
|
943
|
-
return; // already processed
|
|
944
|
-
}
|
|
945
|
-
const leaves = [];
|
|
946
|
-
this.findLeaves(path.node, leaves);
|
|
947
|
-
const b = this.cov.newBranch(
|
|
948
|
-
'binary-expr',
|
|
949
|
-
path.node.loc,
|
|
950
|
-
this.reportLogic
|
|
951
|
-
);
|
|
952
|
-
for (let i = 0; i < leaves.length; i += 1) {
|
|
953
|
-
const leaf = leaves[i];
|
|
954
|
-
const hint = this.hintFor(leaf.node);
|
|
955
|
-
if (hint === 'next') {
|
|
956
|
-
continue;
|
|
957
|
-
}
|
|
958
|
-
|
|
959
|
-
if (this.reportLogic) {
|
|
960
|
-
const increment = this.getBranchLogicIncrement(
|
|
961
|
-
leaf,
|
|
962
|
-
b,
|
|
963
|
-
leaf.node.loc
|
|
964
|
-
);
|
|
965
|
-
if (!increment[0]) {
|
|
966
|
-
continue;
|
|
967
|
-
}
|
|
968
|
-
leaf.parent[leaf.property] = T.sequenceExpression([
|
|
969
|
-
increment[0],
|
|
970
|
-
increment[1]
|
|
971
|
-
]);
|
|
972
|
-
continue;
|
|
973
|
-
}
|
|
974
|
-
|
|
975
|
-
const increment = this.getBranchIncrement(b, leaf.node.loc);
|
|
976
|
-
if (!increment) {
|
|
977
|
-
continue;
|
|
978
|
-
}
|
|
979
|
-
leaf.parent[leaf.property] = T.sequenceExpression([
|
|
980
|
-
increment,
|
|
981
|
-
leaf.node
|
|
982
|
-
]);
|
|
983
|
-
}
|
|
984
|
-
}
|
|
985
|
-
|
|
986
|
-
const codeVisitor = {
|
|
987
|
-
ArrowFunctionExpression: entries(convertArrowExpression, coverFunction),
|
|
988
|
-
AssignmentPattern: entries(coverAssignmentPattern),
|
|
989
|
-
BlockStatement: entries(), // ignore processing only
|
|
990
|
-
ExportDefaultDeclaration: entries(), // ignore processing only
|
|
991
|
-
ExportNamedDeclaration: entries(), // ignore processing only
|
|
992
|
-
ClassMethod: entries(coverFunction),
|
|
993
|
-
ClassDeclaration: entries(parenthesizedExpressionProp('superClass')),
|
|
994
|
-
ClassProperty: entries(coverClassPropDeclarator),
|
|
995
|
-
ClassPrivateProperty: entries(coverClassPropDeclarator),
|
|
996
|
-
ObjectMethod: entries(coverFunction),
|
|
997
|
-
ExpressionStatement: entries(coverStatement),
|
|
998
|
-
BreakStatement: entries(coverStatement),
|
|
999
|
-
ContinueStatement: entries(coverStatement),
|
|
1000
|
-
DebuggerStatement: entries(coverStatement),
|
|
1001
|
-
ReturnStatement: entries(coverStatement),
|
|
1002
|
-
ThrowStatement: entries(coverStatement),
|
|
1003
|
-
TryStatement: entries(coverStatement),
|
|
1004
|
-
VariableDeclaration: entries(), // ignore processing only
|
|
1005
|
-
VariableDeclarator: entries(coverVariableDeclarator),
|
|
1006
|
-
IfStatement: entries(
|
|
1007
|
-
blockProp('consequent'),
|
|
1008
|
-
blockProp('alternate'),
|
|
1009
|
-
coverStatement,
|
|
1010
|
-
coverIfBranches
|
|
1011
|
-
),
|
|
1012
|
-
ForStatement: entries(blockProp('body'), coverStatement),
|
|
1013
|
-
ForInStatement: entries(blockProp('body'), coverStatement),
|
|
1014
|
-
ForOfStatement: entries(blockProp('body'), coverStatement),
|
|
1015
|
-
WhileStatement: entries(blockProp('body'), coverStatement),
|
|
1016
|
-
DoWhileStatement: entries(blockProp('body'), coverStatement),
|
|
1017
|
-
SwitchStatement: entries(createSwitchBranch, coverStatement),
|
|
1018
|
-
SwitchCase: entries(coverSwitchCase),
|
|
1019
|
-
WithStatement: entries(blockProp('body'), coverStatement),
|
|
1020
|
-
FunctionDeclaration: entries(coverFunction),
|
|
1021
|
-
FunctionExpression: entries(coverFunction),
|
|
1022
|
-
LabeledStatement: entries(coverStatement),
|
|
1023
|
-
ConditionalExpression: entries(coverTernary),
|
|
1024
|
-
LogicalExpression: entries(coverLogicalExpression)
|
|
1025
|
-
};
|
|
1026
|
-
const globalTemplateAlteredFunction = template(`
|
|
1027
|
-
var Function = (function(){}).constructor;
|
|
1028
|
-
var global = (new Function(GLOBAL_COVERAGE_SCOPE))();
|
|
1029
|
-
`);
|
|
1030
|
-
const globalTemplateFunction = template(`
|
|
1031
|
-
var global = (new Function(GLOBAL_COVERAGE_SCOPE))();
|
|
1032
|
-
`);
|
|
1033
|
-
const globalTemplateVariable = template(`
|
|
1034
|
-
var global = GLOBAL_COVERAGE_SCOPE;
|
|
1035
|
-
`);
|
|
1036
|
-
// the template to insert at the top of the program.
|
|
1037
|
-
const coverageTemplate = template(
|
|
1038
|
-
`
|
|
1039
|
-
function COVERAGE_FUNCTION () {
|
|
1040
|
-
var path = PATH;
|
|
1041
|
-
var hash = HASH;
|
|
1042
|
-
GLOBAL_COVERAGE_TEMPLATE
|
|
1043
|
-
var gcv = GLOBAL_COVERAGE_VAR;
|
|
1044
|
-
var coverageData = INITIAL;
|
|
1045
|
-
var coverage = global[gcv] || (global[gcv] = {});
|
|
1046
|
-
if (!coverage[path] || coverage[path].hash !== hash) {
|
|
1047
|
-
coverage[path] = coverageData;
|
|
1048
|
-
}
|
|
1049
|
-
|
|
1050
|
-
var actualCoverage = coverage[path];
|
|
1051
|
-
{
|
|
1052
|
-
// @ts-ignore
|
|
1053
|
-
COVERAGE_FUNCTION = function () {
|
|
1054
|
-
return actualCoverage;
|
|
1055
|
-
}
|
|
1056
|
-
}
|
|
1057
|
-
|
|
1058
|
-
return actualCoverage;
|
|
1059
|
-
}
|
|
1060
|
-
`,
|
|
1061
|
-
{ preserveComments: true }
|
|
1062
|
-
);
|
|
1063
|
-
// the rewire plugin (and potentially other babel middleware)
|
|
1064
|
-
// may cause files to be instrumented twice, see:
|
|
1065
|
-
// https://github.com/istanbuljs/babel-plugin-istanbul/issues/94
|
|
1066
|
-
// we should only instrument code for coverage the first time
|
|
1067
|
-
// it's run through istanbul-lib-instrument.
|
|
1068
|
-
function alreadyInstrumented(path, visitState) {
|
|
1069
|
-
return path.scope.hasBinding(visitState.varName);
|
|
1070
|
-
}
|
|
1071
|
-
function shouldIgnoreFile(programNode) {
|
|
1072
|
-
return (
|
|
1073
|
-
programNode.parent &&
|
|
1074
|
-
programNode.parent.comments.some(c => COMMENT_FILE_RE.test(c.value))
|
|
1075
|
-
);
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
/**
|
|
1079
|
-
* programVisitor is a `babel` adaptor for instrumentation.
|
|
1080
|
-
* It returns an object with two methods `enter` and `exit`.
|
|
1081
|
-
* These should be assigned to or called from `Program` entry and exit functions
|
|
1082
|
-
* in a babel visitor.
|
|
1083
|
-
* These functions do not make assumptions about the state set by Babel and thus
|
|
1084
|
-
* can be used in a context other than a Babel plugin.
|
|
1085
|
-
*
|
|
1086
|
-
* The exit function returns an object that currently has the following keys:
|
|
1087
|
-
*
|
|
1088
|
-
* `fileCoverage` - the file coverage object created for the source file.
|
|
1089
|
-
* `sourceMappingURL` - any source mapping URL found when processing the file.
|
|
1090
|
-
*
|
|
1091
|
-
* @param {Object} types - an instance of babel-types.
|
|
1092
|
-
* @param {string} sourceFilePath - the path to source file.
|
|
1093
|
-
* @param {Object} opts - additional options.
|
|
1094
|
-
* @param {string} [opts.coverageVariable=__coverage__] the global coverage variable name.
|
|
1095
|
-
* @param {boolean} [opts.reportLogic=false] report boolean value of logical expressions.
|
|
1096
|
-
* @param {string} [opts.coverageGlobalScope=this] the global coverage variable scope.
|
|
1097
|
-
* @param {boolean} [opts.coverageGlobalScopeFunc=true] use an evaluated function to find coverageGlobalScope.
|
|
1098
|
-
* @param {Array} [opts.ignoreClassMethods=[]] names of methods to ignore by default on classes.
|
|
1099
|
-
* @param {Array} [opts.ignoreLines=false] enable ignore hints for lines (start, end).
|
|
1100
|
-
* @param {object} [opts.inputSourceMap=undefined] the input source map, that maps the uninstrumented code back to the
|
|
1101
|
-
* original code.
|
|
1102
|
-
*/
|
|
1103
|
-
function programVisitor(types, sourceFilePath = 'unknown.js', opts = {}) {
|
|
1104
|
-
const T = types;
|
|
1105
|
-
opts = {
|
|
1106
|
-
...defaults.instrumentVisitor,
|
|
1107
|
-
...opts
|
|
1108
|
-
};
|
|
1109
|
-
const visitState = new VisitState(
|
|
1110
|
-
types,
|
|
1111
|
-
sourceFilePath,
|
|
1112
|
-
opts.inputSourceMap,
|
|
1113
|
-
opts.ignoreClassMethods,
|
|
1114
|
-
opts.reportLogic,
|
|
1115
|
-
opts.ignoreLines
|
|
1116
|
-
);
|
|
1117
|
-
return {
|
|
1118
|
-
enter(path) {
|
|
1119
|
-
if (shouldIgnoreFile(path.find(p => p.isProgram()))) {
|
|
1120
|
-
return;
|
|
1121
|
-
}
|
|
1122
|
-
if (alreadyInstrumented(path, visitState)) {
|
|
1123
|
-
return;
|
|
1124
|
-
}
|
|
1125
|
-
path.traverse(codeVisitor, visitState);
|
|
1126
|
-
},
|
|
1127
|
-
exit(path) {
|
|
1128
|
-
if (alreadyInstrumented(path, visitState)) {
|
|
1129
|
-
return;
|
|
1130
|
-
}
|
|
1131
|
-
visitState.cov.freeze();
|
|
1132
|
-
const coverageData = visitState.cov.toJSON();
|
|
1133
|
-
if (shouldIgnoreFile(path.find(p => p.isProgram()))) {
|
|
1134
|
-
return {
|
|
1135
|
-
fileCoverage: coverageData,
|
|
1136
|
-
sourceMappingURL: visitState.sourceMappingURL
|
|
1137
|
-
};
|
|
1138
|
-
}
|
|
1139
|
-
coverageData[MAGIC_KEY] = MAGIC_VALUE;
|
|
1140
|
-
const hash = createHash(SHA)
|
|
1141
|
-
.update(JSON.stringify(coverageData))
|
|
1142
|
-
.digest('hex');
|
|
1143
|
-
coverageData.hash = hash;
|
|
1144
|
-
if (
|
|
1145
|
-
coverageData.inputSourceMap &&
|
|
1146
|
-
Object.getPrototypeOf(coverageData.inputSourceMap) !==
|
|
1147
|
-
Object.prototype
|
|
1148
|
-
) {
|
|
1149
|
-
coverageData.inputSourceMap = {
|
|
1150
|
-
...coverageData.inputSourceMap
|
|
1151
|
-
};
|
|
1152
|
-
}
|
|
1153
|
-
const coverageNode = T.valueToNode(coverageData);
|
|
1154
|
-
delete coverageData[MAGIC_KEY];
|
|
1155
|
-
delete coverageData.hash;
|
|
1156
|
-
let gvTemplate;
|
|
1157
|
-
if (opts.coverageGlobalScopeFunc) {
|
|
1158
|
-
if (path.scope.getBinding('Function')) {
|
|
1159
|
-
gvTemplate = globalTemplateAlteredFunction({
|
|
1160
|
-
GLOBAL_COVERAGE_SCOPE: T.stringLiteral(
|
|
1161
|
-
'return ' + opts.coverageGlobalScope
|
|
1162
|
-
)
|
|
1163
|
-
});
|
|
1164
|
-
} else {
|
|
1165
|
-
gvTemplate = globalTemplateFunction({
|
|
1166
|
-
GLOBAL_COVERAGE_SCOPE: T.stringLiteral(
|
|
1167
|
-
'return ' + opts.coverageGlobalScope
|
|
1168
|
-
)
|
|
1169
|
-
});
|
|
1170
|
-
}
|
|
1171
|
-
} else {
|
|
1172
|
-
gvTemplate = globalTemplateVariable({
|
|
1173
|
-
GLOBAL_COVERAGE_SCOPE: opts.coverageGlobalScope
|
|
1174
|
-
});
|
|
1175
|
-
}
|
|
1176
|
-
const cv = coverageTemplate({
|
|
1177
|
-
GLOBAL_COVERAGE_VAR: T.stringLiteral(opts.coverageVariable),
|
|
1178
|
-
GLOBAL_COVERAGE_TEMPLATE: gvTemplate,
|
|
1179
|
-
COVERAGE_FUNCTION: T.identifier(visitState.varName),
|
|
1180
|
-
PATH: T.stringLiteral(sourceFilePath),
|
|
1181
|
-
INITIAL: coverageNode,
|
|
1182
|
-
HASH: T.stringLiteral(hash)
|
|
1183
|
-
});
|
|
1184
|
-
// explicitly call this.varName to ensure coverage is always initialized
|
|
1185
|
-
path.node.body.unshift(
|
|
1186
|
-
T.expressionStatement(
|
|
1187
|
-
T.callExpression(T.identifier(visitState.varName), [])
|
|
1188
|
-
)
|
|
1189
|
-
);
|
|
1190
|
-
path.node.body.unshift(cv);
|
|
1191
|
-
return {
|
|
1192
|
-
fileCoverage: coverageData,
|
|
1193
|
-
sourceMappingURL: visitState.sourceMappingURL
|
|
1194
|
-
};
|
|
1195
|
-
}
|
|
1196
|
-
};
|
|
1197
|
-
}
|
|
1198
|
-
|
|
1199
|
-
function originalPositionTryBoth(sourceMap, { line, column }) {
|
|
1200
|
-
const mapping = originalPositionFor(sourceMap, {
|
|
1201
|
-
line,
|
|
1202
|
-
column,
|
|
1203
|
-
bias: GREATEST_LOWER_BOUND
|
|
1204
|
-
});
|
|
1205
|
-
if (mapping.source === null) {
|
|
1206
|
-
return originalPositionFor(sourceMap, {
|
|
1207
|
-
line,
|
|
1208
|
-
column,
|
|
1209
|
-
bias: LEAST_UPPER_BOUND
|
|
1210
|
-
});
|
|
1211
|
-
} else {
|
|
1212
|
-
return mapping;
|
|
1213
|
-
}
|
|
1214
|
-
}
|
|
1215
|
-
|
|
1216
|
-
function tryReadFileSync(filename) {
|
|
1217
|
-
try {
|
|
1218
|
-
return readFileSync(filename, 'utf8');
|
|
1219
|
-
} catch (_) {
|
|
1220
|
-
return undefined;
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
|
|
1224
|
-
visitor = programVisitor;
|
|
1225
|
-
return visitor;
|
|
1226
|
-
}
|
|
1227
|
-
|
|
1228
|
-
var readCoverage;
|
|
1229
|
-
var hasRequiredReadCoverage;
|
|
1230
|
-
|
|
1231
|
-
function requireReadCoverage () {
|
|
1232
|
-
if (hasRequiredReadCoverage) return readCoverage;
|
|
1233
|
-
hasRequiredReadCoverage = 1;
|
|
1234
|
-
const { parseSync, traverse } = require$$0$3;
|
|
1235
|
-
const { defaults } = require$$1$1;
|
|
1236
|
-
const { MAGIC_KEY, MAGIC_VALUE } = requireConstants();
|
|
1237
|
-
|
|
1238
|
-
function getAst(code) {
|
|
1239
|
-
if (typeof code === 'object' && typeof code.type === 'string') {
|
|
1240
|
-
// Assume code is already a babel ast.
|
|
1241
|
-
return code;
|
|
1242
|
-
}
|
|
1243
|
-
|
|
1244
|
-
if (typeof code !== 'string') {
|
|
1245
|
-
throw new Error('Code must be a string');
|
|
1246
|
-
}
|
|
1247
|
-
|
|
1248
|
-
// Parse as leniently as possible
|
|
1249
|
-
return parseSync(code, {
|
|
1250
|
-
babelrc: false,
|
|
1251
|
-
configFile: false,
|
|
1252
|
-
parserOpts: {
|
|
1253
|
-
allowAwaitOutsideFunction: true,
|
|
1254
|
-
allowImportExportEverywhere: true,
|
|
1255
|
-
allowReturnOutsideFunction: true,
|
|
1256
|
-
allowSuperOutsideMethod: true,
|
|
1257
|
-
sourceType: 'unambiguous',
|
|
1258
|
-
plugins: defaults.instrumenter.parserPlugins
|
|
1259
|
-
}
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
|
|
1263
|
-
readCoverage = function readInitialCoverage(code) {
|
|
1264
|
-
const ast = getAst(code);
|
|
1265
|
-
|
|
1266
|
-
let covScope;
|
|
1267
|
-
traverse(ast, {
|
|
1268
|
-
ObjectProperty(path) {
|
|
1269
|
-
const { node } = path;
|
|
1270
|
-
if (
|
|
1271
|
-
!node.computed &&
|
|
1272
|
-
path.get('key').isIdentifier() &&
|
|
1273
|
-
node.key.name === MAGIC_KEY
|
|
1274
|
-
) {
|
|
1275
|
-
const magicValue = path.get('value').evaluate();
|
|
1276
|
-
if (!magicValue.confident || magicValue.value !== MAGIC_VALUE) {
|
|
1277
|
-
return;
|
|
1278
|
-
}
|
|
1279
|
-
covScope =
|
|
1280
|
-
path.scope.getFunctionParent() ||
|
|
1281
|
-
path.scope.getProgramParent();
|
|
1282
|
-
path.stop();
|
|
1283
|
-
}
|
|
1284
|
-
}
|
|
1285
|
-
});
|
|
1286
|
-
|
|
1287
|
-
if (!covScope) {
|
|
1288
|
-
return null;
|
|
1289
|
-
}
|
|
1290
|
-
|
|
1291
|
-
const result = {};
|
|
1292
|
-
|
|
1293
|
-
for (const key of ['path', 'hash', 'gcv', 'coverageData']) {
|
|
1294
|
-
const binding = covScope.getOwnBinding(key);
|
|
1295
|
-
if (!binding) {
|
|
1296
|
-
return null;
|
|
1297
|
-
}
|
|
1298
|
-
const valuePath = binding.path.get('init');
|
|
1299
|
-
const value = valuePath.evaluate();
|
|
1300
|
-
if (!value.confident) {
|
|
1301
|
-
return null;
|
|
1302
|
-
}
|
|
1303
|
-
result[key] = value.value;
|
|
1304
|
-
}
|
|
1305
|
-
|
|
1306
|
-
delete result.coverageData[MAGIC_KEY];
|
|
1307
|
-
delete result.coverageData.hash;
|
|
1308
|
-
|
|
1309
|
-
return result;
|
|
1310
|
-
};
|
|
1311
|
-
return readCoverage;
|
|
1312
|
-
}
|
|
1313
|
-
|
|
1314
|
-
/*
|
|
1315
|
-
Copyright 2012-2015, Yahoo Inc.
|
|
1316
|
-
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
1317
|
-
*/
|
|
1318
|
-
|
|
1319
|
-
var instrumenter;
|
|
1320
|
-
var hasRequiredInstrumenter;
|
|
1321
|
-
|
|
1322
|
-
function requireInstrumenter () {
|
|
1323
|
-
if (hasRequiredInstrumenter) return instrumenter;
|
|
1324
|
-
hasRequiredInstrumenter = 1;
|
|
1325
|
-
const { transformSync } = require$$0$3;
|
|
1326
|
-
const { defaults } = require$$1$1;
|
|
1327
|
-
const programVisitor = requireVisitor();
|
|
1328
|
-
const readInitialCoverage = requireReadCoverage();
|
|
1329
|
-
|
|
1330
|
-
/**
|
|
1331
|
-
* Instrumenter is the public API for the instrument library.
|
|
1332
|
-
* It is typically used for ES5 code. For ES6 code that you
|
|
1333
|
-
* are already running under `babel` use the coverage plugin
|
|
1334
|
-
* instead.
|
|
1335
|
-
* @param {Object} opts optional.
|
|
1336
|
-
* @param {string} [opts.coverageVariable=__coverage__] name of global coverage variable.
|
|
1337
|
-
* @param {boolean} [opts.reportLogic=false] report boolean value of logical expressions.
|
|
1338
|
-
* @param {boolean} [opts.preserveComments=false] preserve comments in output.
|
|
1339
|
-
* @param {boolean} [opts.compact=true] generate compact code.
|
|
1340
|
-
* @param {boolean} [opts.esModules=false] set to true to instrument ES6 modules.
|
|
1341
|
-
* @param {boolean} [opts.autoWrap=false] set to true to allow `return` statements outside of functions.
|
|
1342
|
-
* @param {boolean} [opts.produceSourceMap=false] set to true to produce a source map for the instrumented code.
|
|
1343
|
-
* @param {Array} [opts.ignoreClassMethods=[]] set to array of class method names to ignore for coverage.
|
|
1344
|
-
* @param {Array} [opts.ignoreLines=false] enable ignore hints for lines (start, end).
|
|
1345
|
-
* @param {Function} [opts.sourceMapUrlCallback=null] a callback function that is called when a source map URL
|
|
1346
|
-
* is found in the original code. This function is called with the source file name and the source map URL.
|
|
1347
|
-
* @param {boolean} [opts.debug=false] - turn debugging on.
|
|
1348
|
-
* @param {array} [opts.parserPlugins] - set babel parser plugins, see @istanbuljs/schema for defaults.
|
|
1349
|
-
* @param {string} [opts.coverageGlobalScope=this] the global coverage variable scope.
|
|
1350
|
-
* @param {boolean} [opts.coverageGlobalScopeFunc=true] use an evaluated function to find coverageGlobalScope.
|
|
1351
|
-
* @param {Object} [opts.generatorOpts] - set babel generator options
|
|
1352
|
-
*/
|
|
1353
|
-
class Instrumenter {
|
|
1354
|
-
constructor(opts = {}) {
|
|
1355
|
-
this.opts = {
|
|
1356
|
-
...defaults.instrumenter,
|
|
1357
|
-
...opts
|
|
1358
|
-
};
|
|
1359
|
-
this.fileCoverage = null;
|
|
1360
|
-
this.sourceMap = null;
|
|
1361
|
-
}
|
|
1362
|
-
/**
|
|
1363
|
-
* instrument the supplied code and track coverage against the supplied
|
|
1364
|
-
* filename. It throws if invalid code is passed to it. ES5 and ES6 syntax
|
|
1365
|
-
* is supported. To instrument ES6 modules, make sure that you set the
|
|
1366
|
-
* `esModules` property to `true` when creating the instrumenter.
|
|
1367
|
-
*
|
|
1368
|
-
* @param {string} code - the code to instrument
|
|
1369
|
-
* @param {string} filename - the filename against which to track coverage.
|
|
1370
|
-
* @param {object} [inputSourceMap] - the source map that maps the not instrumented code back to it's original form.
|
|
1371
|
-
* Is assigned to the coverage object and therefore, is available in the json output and can be used to remap the
|
|
1372
|
-
* coverage to the untranspiled source.
|
|
1373
|
-
* @returns {string} the instrumented code.
|
|
1374
|
-
*/
|
|
1375
|
-
instrumentSync(code, filename, inputSourceMap) {
|
|
1376
|
-
if (typeof code !== 'string') {
|
|
1377
|
-
throw new Error('Code must be a string');
|
|
1378
|
-
}
|
|
1379
|
-
filename = filename || String(new Date().getTime()) + '.js';
|
|
1380
|
-
const { opts } = this;
|
|
1381
|
-
let output = {};
|
|
1382
|
-
const babelOpts = {
|
|
1383
|
-
configFile: false,
|
|
1384
|
-
babelrc: false,
|
|
1385
|
-
ast: true,
|
|
1386
|
-
filename: filename || String(new Date().getTime()) + '.js',
|
|
1387
|
-
inputSourceMap,
|
|
1388
|
-
sourceMaps: opts.produceSourceMap,
|
|
1389
|
-
compact: opts.compact,
|
|
1390
|
-
comments: opts.preserveComments,
|
|
1391
|
-
parserOpts: {
|
|
1392
|
-
allowReturnOutsideFunction: opts.autoWrap,
|
|
1393
|
-
sourceType: opts.esModules ? 'module' : 'script',
|
|
1394
|
-
plugins: opts.parserPlugins
|
|
1395
|
-
},
|
|
1396
|
-
generatorOpts: opts.generatorOpts,
|
|
1397
|
-
plugins: [
|
|
1398
|
-
[
|
|
1399
|
-
({ types }) => {
|
|
1400
|
-
const ee = programVisitor(types, filename, {
|
|
1401
|
-
coverageVariable: opts.coverageVariable,
|
|
1402
|
-
reportLogic: opts.reportLogic,
|
|
1403
|
-
coverageGlobalScope: opts.coverageGlobalScope,
|
|
1404
|
-
coverageGlobalScopeFunc:
|
|
1405
|
-
opts.coverageGlobalScopeFunc,
|
|
1406
|
-
ignoreClassMethods: opts.ignoreClassMethods,
|
|
1407
|
-
ignoreLines: opts.ignoreLines,
|
|
1408
|
-
inputSourceMap
|
|
1409
|
-
});
|
|
1410
|
-
|
|
1411
|
-
return {
|
|
1412
|
-
visitor: {
|
|
1413
|
-
Program: {
|
|
1414
|
-
enter: ee.enter,
|
|
1415
|
-
exit(path) {
|
|
1416
|
-
output = ee.exit(path);
|
|
1417
|
-
}
|
|
1418
|
-
}
|
|
1419
|
-
}
|
|
1420
|
-
};
|
|
1421
|
-
}
|
|
1422
|
-
]
|
|
1423
|
-
]
|
|
1424
|
-
};
|
|
1425
|
-
|
|
1426
|
-
const codeMap = transformSync(code, babelOpts);
|
|
1427
|
-
|
|
1428
|
-
if (!output || !output.fileCoverage) {
|
|
1429
|
-
const initialCoverage =
|
|
1430
|
-
readInitialCoverage(codeMap.ast) ||
|
|
1431
|
-
/* istanbul ignore next: paranoid check */ {};
|
|
1432
|
-
this.fileCoverage = initialCoverage.coverageData;
|
|
1433
|
-
this.sourceMap = inputSourceMap;
|
|
1434
|
-
return code;
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
this.fileCoverage = output.fileCoverage;
|
|
1438
|
-
this.sourceMap = codeMap.map;
|
|
1439
|
-
const cb = this.opts.sourceMapUrlCallback;
|
|
1440
|
-
if (cb && output.sourceMappingURL) {
|
|
1441
|
-
cb(filename, output.sourceMappingURL);
|
|
1442
|
-
}
|
|
1443
|
-
|
|
1444
|
-
return codeMap.code;
|
|
1445
|
-
}
|
|
1446
|
-
/**
|
|
1447
|
-
* callback-style instrument method that calls back with an error
|
|
1448
|
-
* as opposed to throwing one. Note that in the current implementation,
|
|
1449
|
-
* the callback will be called in the same process tick and is not asynchronous.
|
|
1450
|
-
*
|
|
1451
|
-
* @param {string} code - the code to instrument
|
|
1452
|
-
* @param {string} filename - the filename against which to track coverage.
|
|
1453
|
-
* @param {Function} callback - the callback
|
|
1454
|
-
* @param {Object} inputSourceMap - the source map that maps the not instrumented code back to it's original form.
|
|
1455
|
-
* Is assigned to the coverage object and therefore, is available in the json output and can be used to remap the
|
|
1456
|
-
* coverage to the untranspiled source.
|
|
1457
|
-
*/
|
|
1458
|
-
instrument(code, filename, callback, inputSourceMap) {
|
|
1459
|
-
if (!callback && typeof filename === 'function') {
|
|
1460
|
-
callback = filename;
|
|
1461
|
-
filename = null;
|
|
1462
|
-
}
|
|
1463
|
-
try {
|
|
1464
|
-
const out = this.instrumentSync(code, filename, inputSourceMap);
|
|
1465
|
-
callback(null, out);
|
|
1466
|
-
} catch (ex) {
|
|
1467
|
-
callback(ex);
|
|
1468
|
-
}
|
|
1469
|
-
}
|
|
1470
|
-
/**
|
|
1471
|
-
* returns the file coverage object for the last file instrumented.
|
|
1472
|
-
* @returns {Object} the file coverage object.
|
|
1473
|
-
*/
|
|
1474
|
-
lastFileCoverage() {
|
|
1475
|
-
return this.fileCoverage;
|
|
1476
|
-
}
|
|
1477
|
-
/**
|
|
1478
|
-
* returns the source map produced for the last file instrumented.
|
|
1479
|
-
* @returns {null|Object} the source map object.
|
|
1480
|
-
*/
|
|
1481
|
-
lastSourceMap() {
|
|
1482
|
-
return this.sourceMap;
|
|
1483
|
-
}
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
instrumenter = Instrumenter;
|
|
1487
|
-
return instrumenter;
|
|
1488
|
-
}
|
|
1489
|
-
|
|
1490
|
-
var src$1;
|
|
1491
|
-
var hasRequiredSrc$1;
|
|
1492
|
-
|
|
1493
|
-
function requireSrc$1 () {
|
|
1494
|
-
if (hasRequiredSrc$1) return src$1;
|
|
1495
|
-
hasRequiredSrc$1 = 1;
|
|
1496
|
-
const { defaults } = require$$1$1;
|
|
1497
|
-
const Instrumenter = requireInstrumenter();
|
|
1498
|
-
const programVisitor = requireVisitor();
|
|
1499
|
-
const readInitialCoverage = requireReadCoverage();
|
|
1500
|
-
|
|
1501
|
-
/**
|
|
1502
|
-
* createInstrumenter creates a new instrumenter with the
|
|
1503
|
-
* supplied options.
|
|
1504
|
-
* @param {Object} opts - instrumenter options. See the documentation
|
|
1505
|
-
* for the Instrumenter class.
|
|
1506
|
-
*/
|
|
1507
|
-
function createInstrumenter(opts) {
|
|
1508
|
-
return new Instrumenter(opts);
|
|
1509
|
-
}
|
|
1510
|
-
|
|
1511
|
-
src$1 = {
|
|
1512
|
-
createInstrumenter,
|
|
1513
|
-
programVisitor,
|
|
1514
|
-
readInitialCoverage,
|
|
1515
|
-
defaultOpts: defaults.instrumenter
|
|
1516
|
-
};
|
|
1517
|
-
return src$1;
|
|
1518
|
-
}
|
|
1519
|
-
|
|
1520
|
-
var srcExports = requireSrc$1();
|
|
1521
|
-
|
|
1522
|
-
var src = {exports: {}};
|
|
1523
|
-
|
|
1524
|
-
var browser$1 = {exports: {}};
|
|
1525
|
-
|
|
1526
|
-
/**
|
|
1527
|
-
* Helpers.
|
|
1528
|
-
*/
|
|
1529
|
-
|
|
1530
|
-
var ms;
|
|
1531
|
-
var hasRequiredMs;
|
|
1532
|
-
|
|
1533
|
-
function requireMs () {
|
|
1534
|
-
if (hasRequiredMs) return ms;
|
|
1535
|
-
hasRequiredMs = 1;
|
|
1536
|
-
var s = 1000;
|
|
1537
|
-
var m = s * 60;
|
|
1538
|
-
var h = m * 60;
|
|
1539
|
-
var d = h * 24;
|
|
1540
|
-
var w = d * 7;
|
|
1541
|
-
var y = d * 365.25;
|
|
1542
|
-
|
|
1543
|
-
/**
|
|
1544
|
-
* Parse or format the given `val`.
|
|
1545
|
-
*
|
|
1546
|
-
* Options:
|
|
1547
|
-
*
|
|
1548
|
-
* - `long` verbose formatting [false]
|
|
1549
|
-
*
|
|
1550
|
-
* @param {String|Number} val
|
|
1551
|
-
* @param {Object} [options]
|
|
1552
|
-
* @throws {Error} throw an error if val is not a non-empty string or a number
|
|
1553
|
-
* @return {String|Number}
|
|
1554
|
-
* @api public
|
|
1555
|
-
*/
|
|
1556
|
-
|
|
1557
|
-
ms = function (val, options) {
|
|
1558
|
-
options = options || {};
|
|
1559
|
-
var type = typeof val;
|
|
1560
|
-
if (type === 'string' && val.length > 0) {
|
|
1561
|
-
return parse(val);
|
|
1562
|
-
} else if (type === 'number' && isFinite(val)) {
|
|
1563
|
-
return options.long ? fmtLong(val) : fmtShort(val);
|
|
1564
|
-
}
|
|
1565
|
-
throw new Error(
|
|
1566
|
-
'val is not a non-empty string or a valid number. val=' +
|
|
1567
|
-
JSON.stringify(val)
|
|
1568
|
-
);
|
|
1569
|
-
};
|
|
1570
|
-
|
|
1571
|
-
/**
|
|
1572
|
-
* Parse the given `str` and return milliseconds.
|
|
1573
|
-
*
|
|
1574
|
-
* @param {String} str
|
|
1575
|
-
* @return {Number}
|
|
1576
|
-
* @api private
|
|
1577
|
-
*/
|
|
1578
|
-
|
|
1579
|
-
function parse(str) {
|
|
1580
|
-
str = String(str);
|
|
1581
|
-
if (str.length > 100) {
|
|
1582
|
-
return;
|
|
1583
|
-
}
|
|
1584
|
-
var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(
|
|
1585
|
-
str
|
|
1586
|
-
);
|
|
1587
|
-
if (!match) {
|
|
1588
|
-
return;
|
|
1589
|
-
}
|
|
1590
|
-
var n = parseFloat(match[1]);
|
|
1591
|
-
var type = (match[2] || 'ms').toLowerCase();
|
|
1592
|
-
switch (type) {
|
|
1593
|
-
case 'years':
|
|
1594
|
-
case 'year':
|
|
1595
|
-
case 'yrs':
|
|
1596
|
-
case 'yr':
|
|
1597
|
-
case 'y':
|
|
1598
|
-
return n * y;
|
|
1599
|
-
case 'weeks':
|
|
1600
|
-
case 'week':
|
|
1601
|
-
case 'w':
|
|
1602
|
-
return n * w;
|
|
1603
|
-
case 'days':
|
|
1604
|
-
case 'day':
|
|
1605
|
-
case 'd':
|
|
1606
|
-
return n * d;
|
|
1607
|
-
case 'hours':
|
|
1608
|
-
case 'hour':
|
|
1609
|
-
case 'hrs':
|
|
1610
|
-
case 'hr':
|
|
1611
|
-
case 'h':
|
|
1612
|
-
return n * h;
|
|
1613
|
-
case 'minutes':
|
|
1614
|
-
case 'minute':
|
|
1615
|
-
case 'mins':
|
|
1616
|
-
case 'min':
|
|
1617
|
-
case 'm':
|
|
1618
|
-
return n * m;
|
|
1619
|
-
case 'seconds':
|
|
1620
|
-
case 'second':
|
|
1621
|
-
case 'secs':
|
|
1622
|
-
case 'sec':
|
|
1623
|
-
case 's':
|
|
1624
|
-
return n * s;
|
|
1625
|
-
case 'milliseconds':
|
|
1626
|
-
case 'millisecond':
|
|
1627
|
-
case 'msecs':
|
|
1628
|
-
case 'msec':
|
|
1629
|
-
case 'ms':
|
|
1630
|
-
return n;
|
|
1631
|
-
default:
|
|
1632
|
-
return undefined;
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
|
|
1636
|
-
/**
|
|
1637
|
-
* Short format for `ms`.
|
|
1638
|
-
*
|
|
1639
|
-
* @param {Number} ms
|
|
1640
|
-
* @return {String}
|
|
1641
|
-
* @api private
|
|
1642
|
-
*/
|
|
1643
|
-
|
|
1644
|
-
function fmtShort(ms) {
|
|
1645
|
-
var msAbs = Math.abs(ms);
|
|
1646
|
-
if (msAbs >= d) {
|
|
1647
|
-
return Math.round(ms / d) + 'd';
|
|
1648
|
-
}
|
|
1649
|
-
if (msAbs >= h) {
|
|
1650
|
-
return Math.round(ms / h) + 'h';
|
|
1651
|
-
}
|
|
1652
|
-
if (msAbs >= m) {
|
|
1653
|
-
return Math.round(ms / m) + 'm';
|
|
1654
|
-
}
|
|
1655
|
-
if (msAbs >= s) {
|
|
1656
|
-
return Math.round(ms / s) + 's';
|
|
1657
|
-
}
|
|
1658
|
-
return ms + 'ms';
|
|
1659
|
-
}
|
|
1660
|
-
|
|
1661
|
-
/**
|
|
1662
|
-
* Long format for `ms`.
|
|
1663
|
-
*
|
|
1664
|
-
* @param {Number} ms
|
|
1665
|
-
* @return {String}
|
|
1666
|
-
* @api private
|
|
1667
|
-
*/
|
|
1668
|
-
|
|
1669
|
-
function fmtLong(ms) {
|
|
1670
|
-
var msAbs = Math.abs(ms);
|
|
1671
|
-
if (msAbs >= d) {
|
|
1672
|
-
return plural(ms, msAbs, d, 'day');
|
|
1673
|
-
}
|
|
1674
|
-
if (msAbs >= h) {
|
|
1675
|
-
return plural(ms, msAbs, h, 'hour');
|
|
1676
|
-
}
|
|
1677
|
-
if (msAbs >= m) {
|
|
1678
|
-
return plural(ms, msAbs, m, 'minute');
|
|
1679
|
-
}
|
|
1680
|
-
if (msAbs >= s) {
|
|
1681
|
-
return plural(ms, msAbs, s, 'second');
|
|
1682
|
-
}
|
|
1683
|
-
return ms + ' ms';
|
|
1684
|
-
}
|
|
1685
|
-
|
|
1686
|
-
/**
|
|
1687
|
-
* Pluralization helper.
|
|
1688
|
-
*/
|
|
1689
|
-
|
|
1690
|
-
function plural(ms, msAbs, n, name) {
|
|
1691
|
-
var isPlural = msAbs >= n * 1.5;
|
|
1692
|
-
return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : '');
|
|
1693
|
-
}
|
|
1694
|
-
return ms;
|
|
1695
|
-
}
|
|
1696
|
-
|
|
1697
|
-
var common;
|
|
1698
|
-
var hasRequiredCommon;
|
|
1699
|
-
|
|
1700
|
-
function requireCommon () {
|
|
1701
|
-
if (hasRequiredCommon) return common;
|
|
1702
|
-
hasRequiredCommon = 1;
|
|
1703
|
-
/**
|
|
1704
|
-
* This is the common logic for both the Node.js and web browser
|
|
1705
|
-
* implementations of `debug()`.
|
|
1706
|
-
*/
|
|
1707
|
-
|
|
1708
|
-
function setup(env) {
|
|
1709
|
-
createDebug.debug = createDebug;
|
|
1710
|
-
createDebug.default = createDebug;
|
|
1711
|
-
createDebug.coerce = coerce;
|
|
1712
|
-
createDebug.disable = disable;
|
|
1713
|
-
createDebug.enable = enable;
|
|
1714
|
-
createDebug.enabled = enabled;
|
|
1715
|
-
createDebug.humanize = requireMs();
|
|
1716
|
-
createDebug.destroy = destroy;
|
|
1717
|
-
|
|
1718
|
-
Object.keys(env).forEach(key => {
|
|
1719
|
-
createDebug[key] = env[key];
|
|
1720
|
-
});
|
|
1721
|
-
|
|
1722
|
-
/**
|
|
1723
|
-
* The currently active debug mode names, and names to skip.
|
|
1724
|
-
*/
|
|
1725
|
-
|
|
1726
|
-
createDebug.names = [];
|
|
1727
|
-
createDebug.skips = [];
|
|
1728
|
-
|
|
1729
|
-
/**
|
|
1730
|
-
* Map of special "%n" handling functions, for the debug "format" argument.
|
|
1731
|
-
*
|
|
1732
|
-
* Valid key names are a single, lower or upper-case letter, i.e. "n" and "N".
|
|
1733
|
-
*/
|
|
1734
|
-
createDebug.formatters = {};
|
|
1735
|
-
|
|
1736
|
-
/**
|
|
1737
|
-
* Selects a color for a debug namespace
|
|
1738
|
-
* @param {String} namespace The namespace string for the debug instance to be colored
|
|
1739
|
-
* @return {Number|String} An ANSI color code for the given namespace
|
|
1740
|
-
* @api private
|
|
1741
|
-
*/
|
|
1742
|
-
function selectColor(namespace) {
|
|
1743
|
-
let hash = 0;
|
|
1744
|
-
|
|
1745
|
-
for (let i = 0; i < namespace.length; i++) {
|
|
1746
|
-
hash = ((hash << 5) - hash) + namespace.charCodeAt(i);
|
|
1747
|
-
hash |= 0; // Convert to 32bit integer
|
|
1748
|
-
}
|
|
1749
|
-
|
|
1750
|
-
return createDebug.colors[Math.abs(hash) % createDebug.colors.length];
|
|
1751
|
-
}
|
|
1752
|
-
createDebug.selectColor = selectColor;
|
|
1753
|
-
|
|
1754
|
-
/**
|
|
1755
|
-
* Create a debugger with the given `namespace`.
|
|
1756
|
-
*
|
|
1757
|
-
* @param {String} namespace
|
|
1758
|
-
* @return {Function}
|
|
1759
|
-
* @api public
|
|
1760
|
-
*/
|
|
1761
|
-
function createDebug(namespace) {
|
|
1762
|
-
let prevTime;
|
|
1763
|
-
let enableOverride = null;
|
|
1764
|
-
let namespacesCache;
|
|
1765
|
-
let enabledCache;
|
|
1766
|
-
|
|
1767
|
-
function debug(...args) {
|
|
1768
|
-
// Disabled?
|
|
1769
|
-
if (!debug.enabled) {
|
|
1770
|
-
return;
|
|
1771
|
-
}
|
|
1772
|
-
|
|
1773
|
-
const self = debug;
|
|
1774
|
-
|
|
1775
|
-
// Set `diff` timestamp
|
|
1776
|
-
const curr = Number(new Date());
|
|
1777
|
-
const ms = curr - (prevTime || curr);
|
|
1778
|
-
self.diff = ms;
|
|
1779
|
-
self.prev = prevTime;
|
|
1780
|
-
self.curr = curr;
|
|
1781
|
-
prevTime = curr;
|
|
1782
|
-
|
|
1783
|
-
args[0] = createDebug.coerce(args[0]);
|
|
1784
|
-
|
|
1785
|
-
if (typeof args[0] !== 'string') {
|
|
1786
|
-
// Anything else let's inspect with %O
|
|
1787
|
-
args.unshift('%O');
|
|
1788
|
-
}
|
|
1789
|
-
|
|
1790
|
-
// Apply any `formatters` transformations
|
|
1791
|
-
let index = 0;
|
|
1792
|
-
args[0] = args[0].replace(/%([a-zA-Z%])/g, (match, format) => {
|
|
1793
|
-
// If we encounter an escaped % then don't increase the array index
|
|
1794
|
-
if (match === '%%') {
|
|
1795
|
-
return '%';
|
|
1796
|
-
}
|
|
1797
|
-
index++;
|
|
1798
|
-
const formatter = createDebug.formatters[format];
|
|
1799
|
-
if (typeof formatter === 'function') {
|
|
1800
|
-
const val = args[index];
|
|
1801
|
-
match = formatter.call(self, val);
|
|
1802
|
-
|
|
1803
|
-
// Now we need to remove `args[index]` since it's inlined in the `format`
|
|
1804
|
-
args.splice(index, 1);
|
|
1805
|
-
index--;
|
|
1806
|
-
}
|
|
1807
|
-
return match;
|
|
1808
|
-
});
|
|
1809
|
-
|
|
1810
|
-
// Apply env-specific formatting (colors, etc.)
|
|
1811
|
-
createDebug.formatArgs.call(self, args);
|
|
1812
|
-
|
|
1813
|
-
const logFn = self.log || createDebug.log;
|
|
1814
|
-
logFn.apply(self, args);
|
|
1815
|
-
}
|
|
1816
|
-
|
|
1817
|
-
debug.namespace = namespace;
|
|
1818
|
-
debug.useColors = createDebug.useColors();
|
|
1819
|
-
debug.color = createDebug.selectColor(namespace);
|
|
1820
|
-
debug.extend = extend;
|
|
1821
|
-
debug.destroy = createDebug.destroy; // XXX Temporary. Will be removed in the next major release.
|
|
1822
|
-
|
|
1823
|
-
Object.defineProperty(debug, 'enabled', {
|
|
1824
|
-
enumerable: true,
|
|
1825
|
-
configurable: false,
|
|
1826
|
-
get: () => {
|
|
1827
|
-
if (enableOverride !== null) {
|
|
1828
|
-
return enableOverride;
|
|
1829
|
-
}
|
|
1830
|
-
if (namespacesCache !== createDebug.namespaces) {
|
|
1831
|
-
namespacesCache = createDebug.namespaces;
|
|
1832
|
-
enabledCache = createDebug.enabled(namespace);
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
return enabledCache;
|
|
1836
|
-
},
|
|
1837
|
-
set: v => {
|
|
1838
|
-
enableOverride = v;
|
|
1839
|
-
}
|
|
1840
|
-
});
|
|
1841
|
-
|
|
1842
|
-
// Env-specific initialization logic for debug instances
|
|
1843
|
-
if (typeof createDebug.init === 'function') {
|
|
1844
|
-
createDebug.init(debug);
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
return debug;
|
|
1848
|
-
}
|
|
1849
|
-
|
|
1850
|
-
function extend(namespace, delimiter) {
|
|
1851
|
-
const newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace);
|
|
1852
|
-
newDebug.log = this.log;
|
|
1853
|
-
return newDebug;
|
|
1854
|
-
}
|
|
1855
|
-
|
|
1856
|
-
/**
|
|
1857
|
-
* Enables a debug mode by namespaces. This can include modes
|
|
1858
|
-
* separated by a colon and wildcards.
|
|
1859
|
-
*
|
|
1860
|
-
* @param {String} namespaces
|
|
1861
|
-
* @api public
|
|
1862
|
-
*/
|
|
1863
|
-
function enable(namespaces) {
|
|
1864
|
-
createDebug.save(namespaces);
|
|
1865
|
-
createDebug.namespaces = namespaces;
|
|
1866
|
-
|
|
1867
|
-
createDebug.names = [];
|
|
1868
|
-
createDebug.skips = [];
|
|
1869
|
-
|
|
1870
|
-
const split = (typeof namespaces === 'string' ? namespaces : '')
|
|
1871
|
-
.trim()
|
|
1872
|
-
.replace(/\s+/g, ',')
|
|
1873
|
-
.split(',')
|
|
1874
|
-
.filter(Boolean);
|
|
1875
|
-
|
|
1876
|
-
for (const ns of split) {
|
|
1877
|
-
if (ns[0] === '-') {
|
|
1878
|
-
createDebug.skips.push(ns.slice(1));
|
|
1879
|
-
} else {
|
|
1880
|
-
createDebug.names.push(ns);
|
|
1881
|
-
}
|
|
1882
|
-
}
|
|
1883
|
-
}
|
|
1884
|
-
|
|
1885
|
-
/**
|
|
1886
|
-
* Checks if the given string matches a namespace template, honoring
|
|
1887
|
-
* asterisks as wildcards.
|
|
1888
|
-
*
|
|
1889
|
-
* @param {String} search
|
|
1890
|
-
* @param {String} template
|
|
1891
|
-
* @return {Boolean}
|
|
1892
|
-
*/
|
|
1893
|
-
function matchesTemplate(search, template) {
|
|
1894
|
-
let searchIndex = 0;
|
|
1895
|
-
let templateIndex = 0;
|
|
1896
|
-
let starIndex = -1;
|
|
1897
|
-
let matchIndex = 0;
|
|
1898
|
-
|
|
1899
|
-
while (searchIndex < search.length) {
|
|
1900
|
-
if (templateIndex < template.length && (template[templateIndex] === search[searchIndex] || template[templateIndex] === '*')) {
|
|
1901
|
-
// Match character or proceed with wildcard
|
|
1902
|
-
if (template[templateIndex] === '*') {
|
|
1903
|
-
starIndex = templateIndex;
|
|
1904
|
-
matchIndex = searchIndex;
|
|
1905
|
-
templateIndex++; // Skip the '*'
|
|
1906
|
-
} else {
|
|
1907
|
-
searchIndex++;
|
|
1908
|
-
templateIndex++;
|
|
1909
|
-
}
|
|
1910
|
-
} else if (starIndex !== -1) { // eslint-disable-line no-negated-condition
|
|
1911
|
-
// Backtrack to the last '*' and try to match more characters
|
|
1912
|
-
templateIndex = starIndex + 1;
|
|
1913
|
-
matchIndex++;
|
|
1914
|
-
searchIndex = matchIndex;
|
|
1915
|
-
} else {
|
|
1916
|
-
return false; // No match
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
1919
|
-
|
|
1920
|
-
// Handle trailing '*' in template
|
|
1921
|
-
while (templateIndex < template.length && template[templateIndex] === '*') {
|
|
1922
|
-
templateIndex++;
|
|
1923
|
-
}
|
|
1924
|
-
|
|
1925
|
-
return templateIndex === template.length;
|
|
1926
|
-
}
|
|
1927
|
-
|
|
1928
|
-
/**
|
|
1929
|
-
* Disable debug output.
|
|
1930
|
-
*
|
|
1931
|
-
* @return {String} namespaces
|
|
1932
|
-
* @api public
|
|
1933
|
-
*/
|
|
1934
|
-
function disable() {
|
|
1935
|
-
const namespaces = [
|
|
1936
|
-
...createDebug.names,
|
|
1937
|
-
...createDebug.skips.map(namespace => '-' + namespace)
|
|
1938
|
-
].join(',');
|
|
1939
|
-
createDebug.enable('');
|
|
1940
|
-
return namespaces;
|
|
1941
|
-
}
|
|
1942
|
-
|
|
1943
|
-
/**
|
|
1944
|
-
* Returns true if the given mode name is enabled, false otherwise.
|
|
1945
|
-
*
|
|
1946
|
-
* @param {String} name
|
|
1947
|
-
* @return {Boolean}
|
|
1948
|
-
* @api public
|
|
1949
|
-
*/
|
|
1950
|
-
function enabled(name) {
|
|
1951
|
-
for (const skip of createDebug.skips) {
|
|
1952
|
-
if (matchesTemplate(name, skip)) {
|
|
1953
|
-
return false;
|
|
1954
|
-
}
|
|
1955
|
-
}
|
|
1956
|
-
|
|
1957
|
-
for (const ns of createDebug.names) {
|
|
1958
|
-
if (matchesTemplate(name, ns)) {
|
|
1959
|
-
return true;
|
|
1960
|
-
}
|
|
1961
|
-
}
|
|
1962
|
-
|
|
1963
|
-
return false;
|
|
1964
|
-
}
|
|
1965
|
-
|
|
1966
|
-
/**
|
|
1967
|
-
* Coerce `val`.
|
|
1968
|
-
*
|
|
1969
|
-
* @param {Mixed} val
|
|
1970
|
-
* @return {Mixed}
|
|
1971
|
-
* @api private
|
|
1972
|
-
*/
|
|
1973
|
-
function coerce(val) {
|
|
1974
|
-
if (val instanceof Error) {
|
|
1975
|
-
return val.stack || val.message;
|
|
1976
|
-
}
|
|
1977
|
-
return val;
|
|
1978
|
-
}
|
|
1979
|
-
|
|
1980
|
-
/**
|
|
1981
|
-
* XXX DO NOT USE. This is a temporary stub function.
|
|
1982
|
-
* XXX It WILL be removed in the next major release.
|
|
1983
|
-
*/
|
|
1984
|
-
function destroy() {
|
|
1985
|
-
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
|
1986
|
-
}
|
|
1987
|
-
|
|
1988
|
-
createDebug.enable(createDebug.load());
|
|
1989
|
-
|
|
1990
|
-
return createDebug;
|
|
1991
|
-
}
|
|
1992
|
-
|
|
1993
|
-
common = setup;
|
|
1994
|
-
return common;
|
|
1995
|
-
}
|
|
1996
|
-
|
|
1997
|
-
/* eslint-env browser */
|
|
1998
|
-
|
|
1999
|
-
var hasRequiredBrowser$1;
|
|
2000
|
-
|
|
2001
|
-
function requireBrowser$1 () {
|
|
2002
|
-
if (hasRequiredBrowser$1) return browser$1.exports;
|
|
2003
|
-
hasRequiredBrowser$1 = 1;
|
|
2004
|
-
(function (module, exports) {
|
|
2005
|
-
/**
|
|
2006
|
-
* This is the web browser implementation of `debug()`.
|
|
2007
|
-
*/
|
|
2008
|
-
|
|
2009
|
-
exports.formatArgs = formatArgs;
|
|
2010
|
-
exports.save = save;
|
|
2011
|
-
exports.load = load;
|
|
2012
|
-
exports.useColors = useColors;
|
|
2013
|
-
exports.storage = localstorage();
|
|
2014
|
-
exports.destroy = (() => {
|
|
2015
|
-
let warned = false;
|
|
2016
|
-
|
|
2017
|
-
return () => {
|
|
2018
|
-
if (!warned) {
|
|
2019
|
-
warned = true;
|
|
2020
|
-
console.warn('Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.');
|
|
2021
|
-
}
|
|
2022
|
-
};
|
|
2023
|
-
})();
|
|
2024
|
-
|
|
2025
|
-
/**
|
|
2026
|
-
* Colors.
|
|
2027
|
-
*/
|
|
2028
|
-
|
|
2029
|
-
exports.colors = [
|
|
2030
|
-
'#0000CC',
|
|
2031
|
-
'#0000FF',
|
|
2032
|
-
'#0033CC',
|
|
2033
|
-
'#0033FF',
|
|
2034
|
-
'#0066CC',
|
|
2035
|
-
'#0066FF',
|
|
2036
|
-
'#0099CC',
|
|
2037
|
-
'#0099FF',
|
|
2038
|
-
'#00CC00',
|
|
2039
|
-
'#00CC33',
|
|
2040
|
-
'#00CC66',
|
|
2041
|
-
'#00CC99',
|
|
2042
|
-
'#00CCCC',
|
|
2043
|
-
'#00CCFF',
|
|
2044
|
-
'#3300CC',
|
|
2045
|
-
'#3300FF',
|
|
2046
|
-
'#3333CC',
|
|
2047
|
-
'#3333FF',
|
|
2048
|
-
'#3366CC',
|
|
2049
|
-
'#3366FF',
|
|
2050
|
-
'#3399CC',
|
|
2051
|
-
'#3399FF',
|
|
2052
|
-
'#33CC00',
|
|
2053
|
-
'#33CC33',
|
|
2054
|
-
'#33CC66',
|
|
2055
|
-
'#33CC99',
|
|
2056
|
-
'#33CCCC',
|
|
2057
|
-
'#33CCFF',
|
|
2058
|
-
'#6600CC',
|
|
2059
|
-
'#6600FF',
|
|
2060
|
-
'#6633CC',
|
|
2061
|
-
'#6633FF',
|
|
2062
|
-
'#66CC00',
|
|
2063
|
-
'#66CC33',
|
|
2064
|
-
'#9900CC',
|
|
2065
|
-
'#9900FF',
|
|
2066
|
-
'#9933CC',
|
|
2067
|
-
'#9933FF',
|
|
2068
|
-
'#99CC00',
|
|
2069
|
-
'#99CC33',
|
|
2070
|
-
'#CC0000',
|
|
2071
|
-
'#CC0033',
|
|
2072
|
-
'#CC0066',
|
|
2073
|
-
'#CC0099',
|
|
2074
|
-
'#CC00CC',
|
|
2075
|
-
'#CC00FF',
|
|
2076
|
-
'#CC3300',
|
|
2077
|
-
'#CC3333',
|
|
2078
|
-
'#CC3366',
|
|
2079
|
-
'#CC3399',
|
|
2080
|
-
'#CC33CC',
|
|
2081
|
-
'#CC33FF',
|
|
2082
|
-
'#CC6600',
|
|
2083
|
-
'#CC6633',
|
|
2084
|
-
'#CC9900',
|
|
2085
|
-
'#CC9933',
|
|
2086
|
-
'#CCCC00',
|
|
2087
|
-
'#CCCC33',
|
|
2088
|
-
'#FF0000',
|
|
2089
|
-
'#FF0033',
|
|
2090
|
-
'#FF0066',
|
|
2091
|
-
'#FF0099',
|
|
2092
|
-
'#FF00CC',
|
|
2093
|
-
'#FF00FF',
|
|
2094
|
-
'#FF3300',
|
|
2095
|
-
'#FF3333',
|
|
2096
|
-
'#FF3366',
|
|
2097
|
-
'#FF3399',
|
|
2098
|
-
'#FF33CC',
|
|
2099
|
-
'#FF33FF',
|
|
2100
|
-
'#FF6600',
|
|
2101
|
-
'#FF6633',
|
|
2102
|
-
'#FF9900',
|
|
2103
|
-
'#FF9933',
|
|
2104
|
-
'#FFCC00',
|
|
2105
|
-
'#FFCC33'
|
|
2106
|
-
];
|
|
2107
|
-
|
|
2108
|
-
/**
|
|
2109
|
-
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
|
2110
|
-
* and the Firebug extension (any Firefox version) are known
|
|
2111
|
-
* to support "%c" CSS customizations.
|
|
2112
|
-
*
|
|
2113
|
-
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
|
2114
|
-
*/
|
|
2115
|
-
|
|
2116
|
-
// eslint-disable-next-line complexity
|
|
2117
|
-
function useColors() {
|
|
2118
|
-
// NB: In an Electron preload script, document will be defined but not fully
|
|
2119
|
-
// initialized. Since we know we're in Chrome, we'll just detect this case
|
|
2120
|
-
// explicitly
|
|
2121
|
-
if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) {
|
|
2122
|
-
return true;
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
// Internet Explorer and Edge do not support colors.
|
|
2126
|
-
if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) {
|
|
2127
|
-
return false;
|
|
2128
|
-
}
|
|
2129
|
-
|
|
2130
|
-
let m;
|
|
2131
|
-
|
|
2132
|
-
// Is webkit? http://stackoverflow.com/a/16459606/376773
|
|
2133
|
-
// document is undefined in react-native: https://github.com/facebook/react-native/pull/1632
|
|
2134
|
-
// eslint-disable-next-line no-return-assign
|
|
2135
|
-
return (typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance) ||
|
|
2136
|
-
// Is firebug? http://stackoverflow.com/a/398120/376773
|
|
2137
|
-
(typeof window !== 'undefined' && window.console && (window.console.firebug || (window.console.exception && window.console.table))) ||
|
|
2138
|
-
// Is firefox >= v31?
|
|
2139
|
-
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
|
2140
|
-
(typeof navigator !== 'undefined' && navigator.userAgent && (m = navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)) && parseInt(m[1], 10) >= 31) ||
|
|
2141
|
-
// Double check webkit in userAgent just in case we are in a worker
|
|
2142
|
-
(typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/));
|
|
2143
|
-
}
|
|
2144
|
-
|
|
2145
|
-
/**
|
|
2146
|
-
* Colorize log arguments if enabled.
|
|
2147
|
-
*
|
|
2148
|
-
* @api public
|
|
2149
|
-
*/
|
|
2150
|
-
|
|
2151
|
-
function formatArgs(args) {
|
|
2152
|
-
args[0] = (this.useColors ? '%c' : '') +
|
|
2153
|
-
this.namespace +
|
|
2154
|
-
(this.useColors ? ' %c' : ' ') +
|
|
2155
|
-
args[0] +
|
|
2156
|
-
(this.useColors ? '%c ' : ' ') +
|
|
2157
|
-
'+' + module.exports.humanize(this.diff);
|
|
2158
|
-
|
|
2159
|
-
if (!this.useColors) {
|
|
2160
|
-
return;
|
|
2161
|
-
}
|
|
2162
|
-
|
|
2163
|
-
const c = 'color: ' + this.color;
|
|
2164
|
-
args.splice(1, 0, c, 'color: inherit');
|
|
2165
|
-
|
|
2166
|
-
// The final "%c" is somewhat tricky, because there could be other
|
|
2167
|
-
// arguments passed either before or after the %c, so we need to
|
|
2168
|
-
// figure out the correct index to insert the CSS into
|
|
2169
|
-
let index = 0;
|
|
2170
|
-
let lastC = 0;
|
|
2171
|
-
args[0].replace(/%[a-zA-Z%]/g, match => {
|
|
2172
|
-
if (match === '%%') {
|
|
2173
|
-
return;
|
|
2174
|
-
}
|
|
2175
|
-
index++;
|
|
2176
|
-
if (match === '%c') {
|
|
2177
|
-
// We only are interested in the *last* %c
|
|
2178
|
-
// (the user may have provided their own)
|
|
2179
|
-
lastC = index;
|
|
2180
|
-
}
|
|
2181
|
-
});
|
|
2182
|
-
|
|
2183
|
-
args.splice(lastC, 0, c);
|
|
2184
|
-
}
|
|
2185
|
-
|
|
2186
|
-
/**
|
|
2187
|
-
* Invokes `console.debug()` when available.
|
|
2188
|
-
* No-op when `console.debug` is not a "function".
|
|
2189
|
-
* If `console.debug` is not available, falls back
|
|
2190
|
-
* to `console.log`.
|
|
2191
|
-
*
|
|
2192
|
-
* @api public
|
|
2193
|
-
*/
|
|
2194
|
-
exports.log = console.debug || console.log || (() => {});
|
|
2195
|
-
|
|
2196
|
-
/**
|
|
2197
|
-
* Save `namespaces`.
|
|
2198
|
-
*
|
|
2199
|
-
* @param {String} namespaces
|
|
2200
|
-
* @api private
|
|
2201
|
-
*/
|
|
2202
|
-
function save(namespaces) {
|
|
2203
|
-
try {
|
|
2204
|
-
if (namespaces) {
|
|
2205
|
-
exports.storage.setItem('debug', namespaces);
|
|
2206
|
-
} else {
|
|
2207
|
-
exports.storage.removeItem('debug');
|
|
2208
|
-
}
|
|
2209
|
-
} catch (error) {
|
|
2210
|
-
// Swallow
|
|
2211
|
-
// XXX (@Qix-) should we be logging these?
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
|
|
2215
|
-
/**
|
|
2216
|
-
* Load `namespaces`.
|
|
2217
|
-
*
|
|
2218
|
-
* @return {String} returns the previously persisted debug modes
|
|
2219
|
-
* @api private
|
|
2220
|
-
*/
|
|
2221
|
-
function load() {
|
|
2222
|
-
let r;
|
|
2223
|
-
try {
|
|
2224
|
-
r = exports.storage.getItem('debug') || exports.storage.getItem('DEBUG') ;
|
|
2225
|
-
} catch (error) {
|
|
2226
|
-
// Swallow
|
|
2227
|
-
// XXX (@Qix-) should we be logging these?
|
|
2228
|
-
}
|
|
2229
|
-
|
|
2230
|
-
// If debug isn't set in LS, and we're in Electron, try to load $DEBUG
|
|
2231
|
-
if (!r && typeof process !== 'undefined' && 'env' in process) {
|
|
2232
|
-
r = process.env.DEBUG;
|
|
2233
|
-
}
|
|
2234
|
-
|
|
2235
|
-
return r;
|
|
2236
|
-
}
|
|
2237
|
-
|
|
2238
|
-
/**
|
|
2239
|
-
* Localstorage attempts to return the localstorage.
|
|
2240
|
-
*
|
|
2241
|
-
* This is necessary because safari throws
|
|
2242
|
-
* when a user disables cookies/localstorage
|
|
2243
|
-
* and you attempt to access it.
|
|
2244
|
-
*
|
|
2245
|
-
* @return {LocalStorage}
|
|
2246
|
-
* @api private
|
|
2247
|
-
*/
|
|
2248
|
-
|
|
2249
|
-
function localstorage() {
|
|
2250
|
-
try {
|
|
2251
|
-
// TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context
|
|
2252
|
-
// The Browser also has localStorage in the global context.
|
|
2253
|
-
return localStorage;
|
|
2254
|
-
} catch (error) {
|
|
2255
|
-
// Swallow
|
|
2256
|
-
// XXX (@Qix-) should we be logging these?
|
|
2257
|
-
}
|
|
2258
|
-
}
|
|
2259
|
-
|
|
2260
|
-
module.exports = requireCommon()(exports);
|
|
2261
|
-
|
|
2262
|
-
const {formatters} = module.exports;
|
|
2263
|
-
|
|
2264
|
-
/**
|
|
2265
|
-
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
|
2266
|
-
*/
|
|
2267
|
-
|
|
2268
|
-
formatters.j = function (v) {
|
|
2269
|
-
try {
|
|
2270
|
-
return JSON.stringify(v);
|
|
2271
|
-
} catch (error) {
|
|
2272
|
-
return '[UnexpectedJSONParseError]: ' + error.message;
|
|
2273
|
-
}
|
|
2274
|
-
};
|
|
2275
|
-
} (browser$1, browser$1.exports));
|
|
2276
|
-
return browser$1.exports;
|
|
2277
|
-
}
|
|
2278
|
-
|
|
2279
|
-
var node = {exports: {}};
|
|
2280
|
-
|
|
2281
|
-
/* eslint-env browser */
|
|
2282
|
-
|
|
2283
|
-
var browser;
|
|
2284
|
-
var hasRequiredBrowser;
|
|
2285
|
-
|
|
2286
|
-
function requireBrowser () {
|
|
2287
|
-
if (hasRequiredBrowser) return browser;
|
|
2288
|
-
hasRequiredBrowser = 1;
|
|
2289
|
-
|
|
2290
|
-
function getChromeVersion() {
|
|
2291
|
-
const matches = /(Chrome|Chromium)\/(?<chromeVersion>\d+)\./.exec(navigator.userAgent);
|
|
2292
|
-
|
|
2293
|
-
if (!matches) {
|
|
2294
|
-
return;
|
|
2295
|
-
}
|
|
2296
|
-
|
|
2297
|
-
return Number.parseInt(matches.groups.chromeVersion, 10);
|
|
2298
|
-
}
|
|
2299
|
-
|
|
2300
|
-
const colorSupport = getChromeVersion() >= 69 ? {
|
|
2301
|
-
level: 1,
|
|
2302
|
-
hasBasic: true,
|
|
2303
|
-
has256: false,
|
|
2304
|
-
has16m: false
|
|
2305
|
-
} : false;
|
|
2306
|
-
|
|
2307
|
-
browser = {
|
|
2308
|
-
stdout: colorSupport,
|
|
2309
|
-
stderr: colorSupport
|
|
2310
|
-
};
|
|
2311
|
-
return browser;
|
|
2312
|
-
}
|
|
2313
|
-
|
|
2314
|
-
/**
|
|
2315
|
-
* Module dependencies.
|
|
2316
|
-
*/
|
|
2317
|
-
|
|
2318
|
-
var hasRequiredNode;
|
|
2319
|
-
|
|
2320
|
-
function requireNode () {
|
|
2321
|
-
if (hasRequiredNode) return node.exports;
|
|
2322
|
-
hasRequiredNode = 1;
|
|
2323
|
-
(function (module, exports) {
|
|
2324
|
-
const tty = require$$0$4;
|
|
2325
|
-
const util = require$$1$2;
|
|
2326
|
-
|
|
2327
|
-
/**
|
|
2328
|
-
* This is the Node.js implementation of `debug()`.
|
|
2329
|
-
*/
|
|
2330
|
-
|
|
2331
|
-
exports.init = init;
|
|
2332
|
-
exports.log = log;
|
|
2333
|
-
exports.formatArgs = formatArgs;
|
|
2334
|
-
exports.save = save;
|
|
2335
|
-
exports.load = load;
|
|
2336
|
-
exports.useColors = useColors;
|
|
2337
|
-
exports.destroy = util.deprecate(
|
|
2338
|
-
() => {},
|
|
2339
|
-
'Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.'
|
|
2340
|
-
);
|
|
2341
|
-
|
|
2342
|
-
/**
|
|
2343
|
-
* Colors.
|
|
2344
|
-
*/
|
|
2345
|
-
|
|
2346
|
-
exports.colors = [6, 2, 3, 4, 5, 1];
|
|
2347
|
-
|
|
2348
|
-
try {
|
|
2349
|
-
// Optional dependency (as in, doesn't need to be installed, NOT like optionalDependencies in package.json)
|
|
2350
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2351
|
-
const supportsColor = requireBrowser();
|
|
2352
|
-
|
|
2353
|
-
if (supportsColor && (supportsColor.stderr || supportsColor).level >= 2) {
|
|
2354
|
-
exports.colors = [
|
|
2355
|
-
20,
|
|
2356
|
-
21,
|
|
2357
|
-
26,
|
|
2358
|
-
27,
|
|
2359
|
-
32,
|
|
2360
|
-
33,
|
|
2361
|
-
38,
|
|
2362
|
-
39,
|
|
2363
|
-
40,
|
|
2364
|
-
41,
|
|
2365
|
-
42,
|
|
2366
|
-
43,
|
|
2367
|
-
44,
|
|
2368
|
-
45,
|
|
2369
|
-
56,
|
|
2370
|
-
57,
|
|
2371
|
-
62,
|
|
2372
|
-
63,
|
|
2373
|
-
68,
|
|
2374
|
-
69,
|
|
2375
|
-
74,
|
|
2376
|
-
75,
|
|
2377
|
-
76,
|
|
2378
|
-
77,
|
|
2379
|
-
78,
|
|
2380
|
-
79,
|
|
2381
|
-
80,
|
|
2382
|
-
81,
|
|
2383
|
-
92,
|
|
2384
|
-
93,
|
|
2385
|
-
98,
|
|
2386
|
-
99,
|
|
2387
|
-
112,
|
|
2388
|
-
113,
|
|
2389
|
-
128,
|
|
2390
|
-
129,
|
|
2391
|
-
134,
|
|
2392
|
-
135,
|
|
2393
|
-
148,
|
|
2394
|
-
149,
|
|
2395
|
-
160,
|
|
2396
|
-
161,
|
|
2397
|
-
162,
|
|
2398
|
-
163,
|
|
2399
|
-
164,
|
|
2400
|
-
165,
|
|
2401
|
-
166,
|
|
2402
|
-
167,
|
|
2403
|
-
168,
|
|
2404
|
-
169,
|
|
2405
|
-
170,
|
|
2406
|
-
171,
|
|
2407
|
-
172,
|
|
2408
|
-
173,
|
|
2409
|
-
178,
|
|
2410
|
-
179,
|
|
2411
|
-
184,
|
|
2412
|
-
185,
|
|
2413
|
-
196,
|
|
2414
|
-
197,
|
|
2415
|
-
198,
|
|
2416
|
-
199,
|
|
2417
|
-
200,
|
|
2418
|
-
201,
|
|
2419
|
-
202,
|
|
2420
|
-
203,
|
|
2421
|
-
204,
|
|
2422
|
-
205,
|
|
2423
|
-
206,
|
|
2424
|
-
207,
|
|
2425
|
-
208,
|
|
2426
|
-
209,
|
|
2427
|
-
214,
|
|
2428
|
-
215,
|
|
2429
|
-
220,
|
|
2430
|
-
221
|
|
2431
|
-
];
|
|
2432
|
-
}
|
|
2433
|
-
} catch (error) {
|
|
2434
|
-
// Swallow - we only care if `supports-color` is available; it doesn't have to be.
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
/**
|
|
2438
|
-
* Build up the default `inspectOpts` object from the environment variables.
|
|
2439
|
-
*
|
|
2440
|
-
* $ DEBUG_COLORS=no DEBUG_DEPTH=10 DEBUG_SHOW_HIDDEN=enabled node script.js
|
|
2441
|
-
*/
|
|
2442
|
-
|
|
2443
|
-
exports.inspectOpts = Object.keys(process.env).filter(key => {
|
|
2444
|
-
return /^debug_/i.test(key);
|
|
2445
|
-
}).reduce((obj, key) => {
|
|
2446
|
-
// Camel-case
|
|
2447
|
-
const prop = key
|
|
2448
|
-
.substring(6)
|
|
2449
|
-
.toLowerCase()
|
|
2450
|
-
.replace(/_([a-z])/g, (_, k) => {
|
|
2451
|
-
return k.toUpperCase();
|
|
2452
|
-
});
|
|
2453
|
-
|
|
2454
|
-
// Coerce string value into JS value
|
|
2455
|
-
let val = process.env[key];
|
|
2456
|
-
if (/^(yes|on|true|enabled)$/i.test(val)) {
|
|
2457
|
-
val = true;
|
|
2458
|
-
} else if (/^(no|off|false|disabled)$/i.test(val)) {
|
|
2459
|
-
val = false;
|
|
2460
|
-
} else if (val === 'null') {
|
|
2461
|
-
val = null;
|
|
2462
|
-
} else {
|
|
2463
|
-
val = Number(val);
|
|
2464
|
-
}
|
|
2465
|
-
|
|
2466
|
-
obj[prop] = val;
|
|
2467
|
-
return obj;
|
|
2468
|
-
}, {});
|
|
2469
|
-
|
|
2470
|
-
/**
|
|
2471
|
-
* Is stdout a TTY? Colored output is enabled when `true`.
|
|
2472
|
-
*/
|
|
2473
|
-
|
|
2474
|
-
function useColors() {
|
|
2475
|
-
return 'colors' in exports.inspectOpts ?
|
|
2476
|
-
Boolean(exports.inspectOpts.colors) :
|
|
2477
|
-
tty.isatty(process.stderr.fd);
|
|
2478
|
-
}
|
|
2479
|
-
|
|
2480
|
-
/**
|
|
2481
|
-
* Adds ANSI color escape codes if enabled.
|
|
2482
|
-
*
|
|
2483
|
-
* @api public
|
|
2484
|
-
*/
|
|
2485
|
-
|
|
2486
|
-
function formatArgs(args) {
|
|
2487
|
-
const {namespace: name, useColors} = this;
|
|
2488
|
-
|
|
2489
|
-
if (useColors) {
|
|
2490
|
-
const c = this.color;
|
|
2491
|
-
const colorCode = '\u001B[3' + (c < 8 ? c : '8;5;' + c);
|
|
2492
|
-
const prefix = ` ${colorCode};1m${name} \u001B[0m`;
|
|
2493
|
-
|
|
2494
|
-
args[0] = prefix + args[0].split('\n').join('\n' + prefix);
|
|
2495
|
-
args.push(colorCode + 'm+' + module.exports.humanize(this.diff) + '\u001B[0m');
|
|
2496
|
-
} else {
|
|
2497
|
-
args[0] = getDate() + name + ' ' + args[0];
|
|
2498
|
-
}
|
|
2499
|
-
}
|
|
2500
|
-
|
|
2501
|
-
function getDate() {
|
|
2502
|
-
if (exports.inspectOpts.hideDate) {
|
|
2503
|
-
return '';
|
|
2504
|
-
}
|
|
2505
|
-
return new Date().toISOString() + ' ';
|
|
2506
|
-
}
|
|
2507
|
-
|
|
2508
|
-
/**
|
|
2509
|
-
* Invokes `util.formatWithOptions()` with the specified arguments and writes to stderr.
|
|
2510
|
-
*/
|
|
2511
|
-
|
|
2512
|
-
function log(...args) {
|
|
2513
|
-
return process.stderr.write(util.formatWithOptions(exports.inspectOpts, ...args) + '\n');
|
|
2514
|
-
}
|
|
2515
|
-
|
|
2516
|
-
/**
|
|
2517
|
-
* Save `namespaces`.
|
|
2518
|
-
*
|
|
2519
|
-
* @param {String} namespaces
|
|
2520
|
-
* @api private
|
|
2521
|
-
*/
|
|
2522
|
-
function save(namespaces) {
|
|
2523
|
-
if (namespaces) {
|
|
2524
|
-
process.env.DEBUG = namespaces;
|
|
2525
|
-
} else {
|
|
2526
|
-
// If you set a process.env field to null or undefined, it gets cast to the
|
|
2527
|
-
// string 'null' or 'undefined'. Just delete instead.
|
|
2528
|
-
delete process.env.DEBUG;
|
|
2529
|
-
}
|
|
2530
|
-
}
|
|
2531
|
-
|
|
2532
|
-
/**
|
|
2533
|
-
* Load `namespaces`.
|
|
2534
|
-
*
|
|
2535
|
-
* @return {String} returns the previously persisted debug modes
|
|
2536
|
-
* @api private
|
|
2537
|
-
*/
|
|
2538
|
-
|
|
2539
|
-
function load() {
|
|
2540
|
-
return process.env.DEBUG;
|
|
2541
|
-
}
|
|
2542
|
-
|
|
2543
|
-
/**
|
|
2544
|
-
* Init logic for `debug` instances.
|
|
2545
|
-
*
|
|
2546
|
-
* Create a new `inspectOpts` object in case `useColors` is set
|
|
2547
|
-
* differently for a particular `debug` instance.
|
|
2548
|
-
*/
|
|
2549
|
-
|
|
2550
|
-
function init(debug) {
|
|
2551
|
-
debug.inspectOpts = {};
|
|
2552
|
-
|
|
2553
|
-
const keys = Object.keys(exports.inspectOpts);
|
|
2554
|
-
for (let i = 0; i < keys.length; i++) {
|
|
2555
|
-
debug.inspectOpts[keys[i]] = exports.inspectOpts[keys[i]];
|
|
2556
|
-
}
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
|
-
module.exports = requireCommon()(exports);
|
|
2560
|
-
|
|
2561
|
-
const {formatters} = module.exports;
|
|
2562
|
-
|
|
2563
|
-
/**
|
|
2564
|
-
* Map %o to `util.inspect()`, all on a single line.
|
|
2565
|
-
*/
|
|
2566
|
-
|
|
2567
|
-
formatters.o = function (v) {
|
|
2568
|
-
this.inspectOpts.colors = this.useColors;
|
|
2569
|
-
return util.inspect(v, this.inspectOpts)
|
|
2570
|
-
.split('\n')
|
|
2571
|
-
.map(str => str.trim())
|
|
2572
|
-
.join(' ');
|
|
2573
|
-
};
|
|
2574
|
-
|
|
2575
|
-
/**
|
|
2576
|
-
* Map %O to `util.inspect()`, allowing multiple lines if needed.
|
|
2577
|
-
*/
|
|
2578
|
-
|
|
2579
|
-
formatters.O = function (v) {
|
|
2580
|
-
this.inspectOpts.colors = this.useColors;
|
|
2581
|
-
return util.inspect(v, this.inspectOpts);
|
|
2582
|
-
};
|
|
2583
|
-
} (node, node.exports));
|
|
2584
|
-
return node.exports;
|
|
2585
|
-
}
|
|
2586
|
-
|
|
2587
|
-
/**
|
|
2588
|
-
* Detect Electron renderer / nwjs process, which is node, but we should
|
|
2589
|
-
* treat as a browser.
|
|
2590
|
-
*/
|
|
2591
|
-
|
|
2592
|
-
var hasRequiredSrc;
|
|
2593
|
-
|
|
2594
|
-
function requireSrc () {
|
|
2595
|
-
if (hasRequiredSrc) return src.exports;
|
|
2596
|
-
hasRequiredSrc = 1;
|
|
2597
|
-
if (typeof process === 'undefined' || process.type === 'renderer' || process.browser === true || process.__nwjs) {
|
|
2598
|
-
src.exports = requireBrowser$1();
|
|
2599
|
-
} else {
|
|
2600
|
-
src.exports = requireNode();
|
|
2601
|
-
}
|
|
2602
|
-
return src.exports;
|
|
2603
|
-
}
|
|
2604
|
-
|
|
2605
|
-
/*
|
|
2606
|
-
Copyright 2015, Yahoo Inc.
|
|
2607
|
-
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
2608
|
-
*/
|
|
2609
|
-
|
|
2610
|
-
var pathutils;
|
|
2611
|
-
var hasRequiredPathutils;
|
|
2612
|
-
|
|
2613
|
-
function requirePathutils () {
|
|
2614
|
-
if (hasRequiredPathutils) return pathutils;
|
|
2615
|
-
hasRequiredPathutils = 1;
|
|
2616
|
-
|
|
2617
|
-
const path = require$$0$5;
|
|
2618
|
-
|
|
2619
|
-
pathutils = {
|
|
2620
|
-
isAbsolute: path.isAbsolute,
|
|
2621
|
-
asAbsolute(file, baseDir) {
|
|
2622
|
-
return path.isAbsolute(file)
|
|
2623
|
-
? file
|
|
2624
|
-
: path.resolve(baseDir || process.cwd(), file);
|
|
2625
|
-
},
|
|
2626
|
-
relativeTo(file, origFile) {
|
|
2627
|
-
return path.isAbsolute(file)
|
|
2628
|
-
? file
|
|
2629
|
-
: path.resolve(path.dirname(origFile), file);
|
|
2630
|
-
}
|
|
2631
|
-
};
|
|
2632
|
-
return pathutils;
|
|
2633
|
-
}
|
|
2634
|
-
|
|
2635
|
-
/*
|
|
2636
|
-
Copyright 2015, Yahoo Inc.
|
|
2637
|
-
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
2638
|
-
*/
|
|
2639
|
-
|
|
2640
|
-
var mapped;
|
|
2641
|
-
var hasRequiredMapped;
|
|
2642
|
-
|
|
2643
|
-
function requireMapped () {
|
|
2644
|
-
if (hasRequiredMapped) return mapped;
|
|
2645
|
-
hasRequiredMapped = 1;
|
|
2646
|
-
|
|
2647
|
-
const { FileCoverage } = require$$0.classes;
|
|
2648
|
-
|
|
2649
|
-
function locString(loc) {
|
|
2650
|
-
return [
|
|
2651
|
-
loc.start.line,
|
|
2652
|
-
loc.start.column,
|
|
2653
|
-
loc.end.line,
|
|
2654
|
-
loc.end.column
|
|
2655
|
-
].join(':');
|
|
2656
|
-
}
|
|
2657
|
-
|
|
2658
|
-
class MappedCoverage extends FileCoverage {
|
|
2659
|
-
constructor(pathOrObj) {
|
|
2660
|
-
super(pathOrObj);
|
|
2661
|
-
|
|
2662
|
-
this.meta = {
|
|
2663
|
-
last: {
|
|
2664
|
-
s: 0,
|
|
2665
|
-
f: 0,
|
|
2666
|
-
b: 0
|
|
2667
|
-
},
|
|
2668
|
-
seen: {}
|
|
2669
|
-
};
|
|
2670
|
-
}
|
|
2671
|
-
|
|
2672
|
-
addStatement(loc, hits) {
|
|
2673
|
-
const key = 's:' + locString(loc);
|
|
2674
|
-
const { meta } = this;
|
|
2675
|
-
let index = meta.seen[key];
|
|
2676
|
-
|
|
2677
|
-
if (index === undefined) {
|
|
2678
|
-
index = meta.last.s;
|
|
2679
|
-
meta.last.s += 1;
|
|
2680
|
-
meta.seen[key] = index;
|
|
2681
|
-
this.statementMap[index] = this.cloneLocation(loc);
|
|
2682
|
-
}
|
|
2683
|
-
|
|
2684
|
-
this.s[index] = this.s[index] || 0;
|
|
2685
|
-
this.s[index] += hits;
|
|
2686
|
-
return index;
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
|
-
addFunction(name, decl, loc, hits) {
|
|
2690
|
-
const key = 'f:' + locString(decl);
|
|
2691
|
-
const { meta } = this;
|
|
2692
|
-
let index = meta.seen[key];
|
|
2693
|
-
|
|
2694
|
-
if (index === undefined) {
|
|
2695
|
-
index = meta.last.f;
|
|
2696
|
-
meta.last.f += 1;
|
|
2697
|
-
meta.seen[key] = index;
|
|
2698
|
-
name = name || `(unknown_${index})`;
|
|
2699
|
-
this.fnMap[index] = {
|
|
2700
|
-
name,
|
|
2701
|
-
decl: this.cloneLocation(decl),
|
|
2702
|
-
loc: this.cloneLocation(loc)
|
|
2703
|
-
};
|
|
2704
|
-
}
|
|
2705
|
-
|
|
2706
|
-
this.f[index] = this.f[index] || 0;
|
|
2707
|
-
this.f[index] += hits;
|
|
2708
|
-
return index;
|
|
2709
|
-
}
|
|
2710
|
-
|
|
2711
|
-
addBranch(type, loc, branchLocations, hits) {
|
|
2712
|
-
const key = ['b', ...branchLocations.map(l => locString(l))].join(':');
|
|
2713
|
-
const { meta } = this;
|
|
2714
|
-
let index = meta.seen[key];
|
|
2715
|
-
if (index === undefined) {
|
|
2716
|
-
index = meta.last.b;
|
|
2717
|
-
meta.last.b += 1;
|
|
2718
|
-
meta.seen[key] = index;
|
|
2719
|
-
this.branchMap[index] = {
|
|
2720
|
-
loc,
|
|
2721
|
-
type,
|
|
2722
|
-
locations: branchLocations.map(l => this.cloneLocation(l))
|
|
2723
|
-
};
|
|
2724
|
-
}
|
|
2725
|
-
|
|
2726
|
-
if (!this.b[index]) {
|
|
2727
|
-
this.b[index] = branchLocations.map(() => 0);
|
|
2728
|
-
}
|
|
2729
|
-
|
|
2730
|
-
hits.forEach((hit, i) => {
|
|
2731
|
-
this.b[index][i] += hit;
|
|
2732
|
-
});
|
|
2733
|
-
return index;
|
|
2734
|
-
}
|
|
2735
|
-
|
|
2736
|
-
/* Returns a clone of the location object with only the attributes of interest */
|
|
2737
|
-
cloneLocation(loc) {
|
|
2738
|
-
return {
|
|
2739
|
-
start: {
|
|
2740
|
-
line: loc.start.line,
|
|
2741
|
-
column: loc.start.column
|
|
2742
|
-
},
|
|
2743
|
-
end: {
|
|
2744
|
-
line: loc.end.line,
|
|
2745
|
-
column: loc.end.column
|
|
2746
|
-
}
|
|
2747
|
-
};
|
|
2748
|
-
}
|
|
2749
|
-
}
|
|
2750
|
-
|
|
2751
|
-
mapped = {
|
|
2752
|
-
MappedCoverage
|
|
2753
|
-
};
|
|
2754
|
-
return mapped;
|
|
2755
|
-
}
|
|
2756
|
-
|
|
2757
|
-
var getMapping_1;
|
|
2758
|
-
var hasRequiredGetMapping;
|
|
2759
|
-
|
|
2760
|
-
function requireGetMapping () {
|
|
2761
|
-
if (hasRequiredGetMapping) return getMapping_1;
|
|
2762
|
-
hasRequiredGetMapping = 1;
|
|
2763
|
-
|
|
2764
|
-
const pathutils = requirePathutils();
|
|
2765
|
-
const {
|
|
2766
|
-
originalPositionFor,
|
|
2767
|
-
allGeneratedPositionsFor,
|
|
2768
|
-
GREATEST_LOWER_BOUND,
|
|
2769
|
-
LEAST_UPPER_BOUND
|
|
2770
|
-
} = require$$3;
|
|
2771
|
-
|
|
2772
|
-
/**
|
|
2773
|
-
* AST ranges are inclusive for start positions and exclusive for end positions.
|
|
2774
|
-
* Source maps are also logically ranges over text, though interacting with
|
|
2775
|
-
* them is generally achieved by working with explicit positions.
|
|
2776
|
-
*
|
|
2777
|
-
* When finding the _end_ location of an AST item, the range behavior is
|
|
2778
|
-
* important because what we're asking for is the _end_ of whatever range
|
|
2779
|
-
* corresponds to the end location we seek.
|
|
2780
|
-
*
|
|
2781
|
-
* This boils down to the following steps, conceptually, though the source-map
|
|
2782
|
-
* library doesn't expose primitives to do this nicely:
|
|
2783
|
-
*
|
|
2784
|
-
* 1. Find the range on the generated file that ends at, or exclusively
|
|
2785
|
-
* contains the end position of the AST node.
|
|
2786
|
-
* 2. Find the range on the original file that corresponds to
|
|
2787
|
-
* that generated range.
|
|
2788
|
-
* 3. Find the _end_ location of that original range.
|
|
2789
|
-
*/
|
|
2790
|
-
function originalEndPositionFor(sourceMap, generatedEnd) {
|
|
2791
|
-
// Given the generated location, find the original location of the mapping
|
|
2792
|
-
// that corresponds to a range on the generated file that overlaps the
|
|
2793
|
-
// generated file end location. Note however that this position on its
|
|
2794
|
-
// own is not useful because it is the position of the _start_ of the range
|
|
2795
|
-
// on the original file, and we want the _end_ of the range.
|
|
2796
|
-
let beforeEndMapping = originalPositionTryBoth(
|
|
2797
|
-
sourceMap,
|
|
2798
|
-
generatedEnd.line,
|
|
2799
|
-
generatedEnd.column - 1
|
|
2800
|
-
);
|
|
2801
|
-
if (beforeEndMapping.source === null) {
|
|
2802
|
-
// search the previous lines as the mapping was not found on the same line
|
|
2803
|
-
for (
|
|
2804
|
-
let line = generatedEnd.line;
|
|
2805
|
-
line > 0 && beforeEndMapping.source === null;
|
|
2806
|
-
line--
|
|
2807
|
-
) {
|
|
2808
|
-
beforeEndMapping = originalPositionTryBoth(
|
|
2809
|
-
sourceMap,
|
|
2810
|
-
line,
|
|
2811
|
-
Infinity
|
|
2812
|
-
);
|
|
2813
|
-
}
|
|
2814
|
-
if (beforeEndMapping.source === null) {
|
|
2815
|
-
return null;
|
|
2816
|
-
}
|
|
2817
|
-
}
|
|
2818
|
-
|
|
2819
|
-
// Convert that original position back to a generated one, with a bump
|
|
2820
|
-
// to the right, and a rightward bias. Since 'generatedPositionFor' searches
|
|
2821
|
-
// for mappings in the original-order sorted list, this will find the
|
|
2822
|
-
// mapping that corresponds to the one immediately after the
|
|
2823
|
-
// beforeEndMapping mapping.
|
|
2824
|
-
const afterEndMappings = allGeneratedPositionsFor(sourceMap, {
|
|
2825
|
-
source: beforeEndMapping.source,
|
|
2826
|
-
line: beforeEndMapping.line,
|
|
2827
|
-
column: beforeEndMapping.column + 1,
|
|
2828
|
-
bias: LEAST_UPPER_BOUND
|
|
2829
|
-
});
|
|
2830
|
-
|
|
2831
|
-
for (let i = 0; i < afterEndMappings.length; i++) {
|
|
2832
|
-
const afterEndMapping = afterEndMappings[i];
|
|
2833
|
-
if (afterEndMapping.line === null) continue;
|
|
2834
|
-
|
|
2835
|
-
const original = originalPositionFor(sourceMap, afterEndMapping);
|
|
2836
|
-
// If the lines match, it means that something comes after our mapping,
|
|
2837
|
-
// so it must end where this one begins.
|
|
2838
|
-
if (original.line === beforeEndMapping.line) return original;
|
|
2839
|
-
}
|
|
2840
|
-
|
|
2841
|
-
// If a generated mapping wasn't found (or all that were found were not on
|
|
2842
|
-
// the same line), then there's nothing after this range and we can
|
|
2843
|
-
// consider it to extend to infinity.
|
|
2844
|
-
return {
|
|
2845
|
-
source: beforeEndMapping.source,
|
|
2846
|
-
line: beforeEndMapping.line,
|
|
2847
|
-
column: Infinity
|
|
2848
|
-
};
|
|
2849
|
-
}
|
|
2850
|
-
|
|
2851
|
-
/**
|
|
2852
|
-
* Attempts to determine the original source position, first
|
|
2853
|
-
* returning the closest element to the left (GREATEST_LOWER_BOUND),
|
|
2854
|
-
* and next returning the closest element to the right (LEAST_UPPER_BOUND).
|
|
2855
|
-
*/
|
|
2856
|
-
function originalPositionTryBoth(sourceMap, line, column) {
|
|
2857
|
-
const mapping = originalPositionFor(sourceMap, {
|
|
2858
|
-
line,
|
|
2859
|
-
column,
|
|
2860
|
-
bias: GREATEST_LOWER_BOUND
|
|
2861
|
-
});
|
|
2862
|
-
if (mapping.source === null) {
|
|
2863
|
-
return originalPositionFor(sourceMap, {
|
|
2864
|
-
line,
|
|
2865
|
-
column,
|
|
2866
|
-
bias: LEAST_UPPER_BOUND
|
|
2867
|
-
});
|
|
2868
|
-
} else {
|
|
2869
|
-
return mapping;
|
|
2870
|
-
}
|
|
2871
|
-
}
|
|
2872
|
-
|
|
2873
|
-
function isInvalidPosition(pos) {
|
|
2874
|
-
return (
|
|
2875
|
-
!pos ||
|
|
2876
|
-
typeof pos.line !== 'number' ||
|
|
2877
|
-
typeof pos.column !== 'number' ||
|
|
2878
|
-
pos.line < 0 ||
|
|
2879
|
-
pos.column < 0
|
|
2880
|
-
);
|
|
2881
|
-
}
|
|
2882
|
-
|
|
2883
|
-
/**
|
|
2884
|
-
* determines the original position for a given location
|
|
2885
|
-
* @param {SourceMapConsumer} sourceMap the source map
|
|
2886
|
-
* @param {Object} generatedLocation the original location Object
|
|
2887
|
-
* @returns {Object} the remapped location Object
|
|
2888
|
-
*/
|
|
2889
|
-
function getMapping(sourceMap, generatedLocation, origFile) {
|
|
2890
|
-
if (!generatedLocation) {
|
|
2891
|
-
return null;
|
|
2892
|
-
}
|
|
2893
|
-
|
|
2894
|
-
if (
|
|
2895
|
-
isInvalidPosition(generatedLocation.start) ||
|
|
2896
|
-
isInvalidPosition(generatedLocation.end)
|
|
2897
|
-
) {
|
|
2898
|
-
return null;
|
|
2899
|
-
}
|
|
2900
|
-
|
|
2901
|
-
const start = originalPositionTryBoth(
|
|
2902
|
-
sourceMap,
|
|
2903
|
-
generatedLocation.start.line,
|
|
2904
|
-
generatedLocation.start.column
|
|
2905
|
-
);
|
|
2906
|
-
let end = originalEndPositionFor(sourceMap, generatedLocation.end);
|
|
2907
|
-
|
|
2908
|
-
/* istanbul ignore if: edge case too hard to test for */
|
|
2909
|
-
if (!(start && end)) {
|
|
2910
|
-
return null;
|
|
2911
|
-
}
|
|
2912
|
-
|
|
2913
|
-
if (!(start.source && end.source)) {
|
|
2914
|
-
return null;
|
|
2915
|
-
}
|
|
2916
|
-
|
|
2917
|
-
if (start.source !== end.source) {
|
|
2918
|
-
return null;
|
|
2919
|
-
}
|
|
2920
|
-
|
|
2921
|
-
/* istanbul ignore if: edge case too hard to test for */
|
|
2922
|
-
if (start.line === null || start.column === null) {
|
|
2923
|
-
return null;
|
|
2924
|
-
}
|
|
2925
|
-
|
|
2926
|
-
/* istanbul ignore if: edge case too hard to test for */
|
|
2927
|
-
if (end.line === null || end.column === null) {
|
|
2928
|
-
return null;
|
|
2929
|
-
}
|
|
2930
|
-
|
|
2931
|
-
if (start.line === end.line && start.column === end.column) {
|
|
2932
|
-
end = originalPositionFor(sourceMap, {
|
|
2933
|
-
line: generatedLocation.end.line,
|
|
2934
|
-
column: generatedLocation.end.column,
|
|
2935
|
-
bias: LEAST_UPPER_BOUND
|
|
2936
|
-
});
|
|
2937
|
-
end.column -= 1;
|
|
2938
|
-
}
|
|
2939
|
-
|
|
2940
|
-
return {
|
|
2941
|
-
source: pathutils.relativeTo(start.source, origFile),
|
|
2942
|
-
loc: {
|
|
2943
|
-
start: {
|
|
2944
|
-
line: start.line,
|
|
2945
|
-
column: start.column
|
|
2946
|
-
},
|
|
2947
|
-
end: {
|
|
2948
|
-
line: end.line,
|
|
2949
|
-
column: end.column
|
|
2950
|
-
}
|
|
2951
|
-
}
|
|
2952
|
-
};
|
|
2953
|
-
}
|
|
2954
|
-
|
|
2955
|
-
getMapping_1 = getMapping;
|
|
2956
|
-
return getMapping_1;
|
|
2957
|
-
}
|
|
2958
|
-
|
|
2959
|
-
/*
|
|
2960
|
-
Copyright 2015, Yahoo Inc.
|
|
2961
|
-
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
2962
|
-
*/
|
|
2963
|
-
|
|
2964
|
-
var transformUtils;
|
|
2965
|
-
var hasRequiredTransformUtils;
|
|
2966
|
-
|
|
2967
|
-
function requireTransformUtils () {
|
|
2968
|
-
if (hasRequiredTransformUtils) return transformUtils;
|
|
2969
|
-
hasRequiredTransformUtils = 1;
|
|
2970
|
-
|
|
2971
|
-
function getUniqueKey(pathname) {
|
|
2972
|
-
return pathname.replace(/[\\/]/g, '_');
|
|
2973
|
-
}
|
|
2974
|
-
|
|
2975
|
-
function getOutput(cache) {
|
|
2976
|
-
return Object.values(cache).reduce(
|
|
2977
|
-
(output, { file, mappedCoverage }) => ({
|
|
2978
|
-
...output,
|
|
2979
|
-
[file]: mappedCoverage
|
|
2980
|
-
}),
|
|
2981
|
-
{}
|
|
2982
|
-
);
|
|
2983
|
-
}
|
|
2984
|
-
|
|
2985
|
-
transformUtils = { getUniqueKey, getOutput };
|
|
2986
|
-
return transformUtils;
|
|
2987
|
-
}
|
|
2988
|
-
|
|
2989
|
-
/*
|
|
2990
|
-
Copyright 2015, Yahoo Inc.
|
|
2991
|
-
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
2992
|
-
*/
|
|
2993
|
-
|
|
2994
|
-
var transformer;
|
|
2995
|
-
var hasRequiredTransformer;
|
|
2996
|
-
|
|
2997
|
-
function requireTransformer () {
|
|
2998
|
-
if (hasRequiredTransformer) return transformer;
|
|
2999
|
-
hasRequiredTransformer = 1;
|
|
3000
|
-
|
|
3001
|
-
const debug = requireSrc()('istanbuljs');
|
|
3002
|
-
const libCoverage = require$$0;
|
|
3003
|
-
const { MappedCoverage } = requireMapped();
|
|
3004
|
-
const getMapping = requireGetMapping();
|
|
3005
|
-
const { getUniqueKey, getOutput } = requireTransformUtils();
|
|
3006
|
-
|
|
3007
|
-
class SourceMapTransformer {
|
|
3008
|
-
constructor(finder, opts = {}) {
|
|
3009
|
-
this.finder = finder;
|
|
3010
|
-
this.baseDir = opts.baseDir || process.cwd();
|
|
3011
|
-
this.resolveMapping = opts.getMapping || getMapping;
|
|
3012
|
-
}
|
|
3013
|
-
|
|
3014
|
-
processFile(fc, sourceMap, coverageMapper) {
|
|
3015
|
-
let changes = 0;
|
|
3016
|
-
|
|
3017
|
-
Object.entries(fc.statementMap).forEach(([s, loc]) => {
|
|
3018
|
-
const hits = fc.s[s];
|
|
3019
|
-
const mapping = this.resolveMapping(sourceMap, loc, fc.path);
|
|
3020
|
-
|
|
3021
|
-
if (mapping) {
|
|
3022
|
-
changes += 1;
|
|
3023
|
-
const mappedCoverage = coverageMapper(mapping.source);
|
|
3024
|
-
mappedCoverage.addStatement(mapping.loc, hits);
|
|
3025
|
-
}
|
|
3026
|
-
});
|
|
3027
|
-
|
|
3028
|
-
Object.entries(fc.fnMap).forEach(([f, fnMeta]) => {
|
|
3029
|
-
const hits = fc.f[f];
|
|
3030
|
-
const mapping = this.resolveMapping(
|
|
3031
|
-
sourceMap,
|
|
3032
|
-
fnMeta.decl,
|
|
3033
|
-
fc.path
|
|
3034
|
-
);
|
|
3035
|
-
|
|
3036
|
-
const spanMapping = this.resolveMapping(
|
|
3037
|
-
sourceMap,
|
|
3038
|
-
fnMeta.loc,
|
|
3039
|
-
fc.path
|
|
3040
|
-
);
|
|
3041
|
-
|
|
3042
|
-
if (
|
|
3043
|
-
mapping &&
|
|
3044
|
-
spanMapping &&
|
|
3045
|
-
mapping.source === spanMapping.source
|
|
3046
|
-
) {
|
|
3047
|
-
changes += 1;
|
|
3048
|
-
const mappedCoverage = coverageMapper(mapping.source);
|
|
3049
|
-
mappedCoverage.addFunction(
|
|
3050
|
-
fnMeta.name,
|
|
3051
|
-
mapping.loc,
|
|
3052
|
-
spanMapping.loc,
|
|
3053
|
-
hits
|
|
3054
|
-
);
|
|
3055
|
-
}
|
|
3056
|
-
});
|
|
3057
|
-
|
|
3058
|
-
Object.entries(fc.branchMap).forEach(([b, branchMeta]) => {
|
|
3059
|
-
const hits = fc.b[b];
|
|
3060
|
-
const locs = [];
|
|
3061
|
-
const mappedHits = [];
|
|
3062
|
-
let source;
|
|
3063
|
-
let skip;
|
|
3064
|
-
|
|
3065
|
-
branchMeta.locations.forEach((loc, i) => {
|
|
3066
|
-
const mapping = this.resolveMapping(sourceMap, loc, fc.path);
|
|
3067
|
-
if (mapping) {
|
|
3068
|
-
if (!source) {
|
|
3069
|
-
source = mapping.source;
|
|
3070
|
-
}
|
|
3071
|
-
|
|
3072
|
-
if (mapping.source !== source) {
|
|
3073
|
-
skip = true;
|
|
3074
|
-
}
|
|
3075
|
-
|
|
3076
|
-
locs.push(mapping.loc);
|
|
3077
|
-
mappedHits.push(hits[i]);
|
|
3078
|
-
}
|
|
3079
|
-
// Check if this is an implicit else
|
|
3080
|
-
else if (
|
|
3081
|
-
source &&
|
|
3082
|
-
branchMeta.type === 'if' &&
|
|
3083
|
-
i > 0 &&
|
|
3084
|
-
loc.start.line === undefined &&
|
|
3085
|
-
loc.start.end === undefined &&
|
|
3086
|
-
loc.end.line === undefined &&
|
|
3087
|
-
loc.end.end === undefined
|
|
3088
|
-
) {
|
|
3089
|
-
locs.push(loc);
|
|
3090
|
-
mappedHits.push(hits[i]);
|
|
3091
|
-
}
|
|
3092
|
-
});
|
|
3093
|
-
|
|
3094
|
-
const locMapping = branchMeta.loc
|
|
3095
|
-
? this.resolveMapping(sourceMap, branchMeta.loc, fc.path)
|
|
3096
|
-
: null;
|
|
3097
|
-
|
|
3098
|
-
if (!skip && locs.length > 0) {
|
|
3099
|
-
changes += 1;
|
|
3100
|
-
const mappedCoverage = coverageMapper(source);
|
|
3101
|
-
mappedCoverage.addBranch(
|
|
3102
|
-
branchMeta.type,
|
|
3103
|
-
locMapping ? locMapping.loc : locs[0],
|
|
3104
|
-
locs,
|
|
3105
|
-
mappedHits
|
|
3106
|
-
);
|
|
3107
|
-
}
|
|
3108
|
-
});
|
|
3109
|
-
|
|
3110
|
-
return changes > 0;
|
|
3111
|
-
}
|
|
3112
|
-
|
|
3113
|
-
async transform(coverageMap) {
|
|
3114
|
-
const uniqueFiles = {};
|
|
3115
|
-
const getMappedCoverage = file => {
|
|
3116
|
-
const key = getUniqueKey(file);
|
|
3117
|
-
if (!uniqueFiles[key]) {
|
|
3118
|
-
uniqueFiles[key] = {
|
|
3119
|
-
file,
|
|
3120
|
-
mappedCoverage: new MappedCoverage(file)
|
|
3121
|
-
};
|
|
3122
|
-
}
|
|
3123
|
-
|
|
3124
|
-
return uniqueFiles[key].mappedCoverage;
|
|
3125
|
-
};
|
|
3126
|
-
|
|
3127
|
-
for (const file of coverageMap.files()) {
|
|
3128
|
-
const fc = coverageMap.fileCoverageFor(file);
|
|
3129
|
-
const sourceMap = await this.finder(file, fc);
|
|
3130
|
-
|
|
3131
|
-
if (sourceMap) {
|
|
3132
|
-
const changed = this.processFile(
|
|
3133
|
-
fc,
|
|
3134
|
-
sourceMap,
|
|
3135
|
-
getMappedCoverage
|
|
3136
|
-
);
|
|
3137
|
-
if (!changed) {
|
|
3138
|
-
debug(`File [${file}] ignored, nothing could be mapped`);
|
|
3139
|
-
}
|
|
3140
|
-
} else {
|
|
3141
|
-
uniqueFiles[getUniqueKey(file)] = {
|
|
3142
|
-
file,
|
|
3143
|
-
mappedCoverage: new MappedCoverage(fc)
|
|
3144
|
-
};
|
|
3145
|
-
}
|
|
3146
|
-
}
|
|
3147
|
-
|
|
3148
|
-
return libCoverage.createCoverageMap(getOutput(uniqueFiles));
|
|
3149
|
-
}
|
|
3150
|
-
}
|
|
3151
|
-
|
|
3152
|
-
transformer = {
|
|
3153
|
-
SourceMapTransformer
|
|
3154
|
-
};
|
|
3155
|
-
return transformer;
|
|
3156
|
-
}
|
|
3157
|
-
|
|
3158
|
-
/*
|
|
3159
|
-
Copyright 2015, Yahoo Inc.
|
|
3160
|
-
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
3161
|
-
*/
|
|
3162
|
-
|
|
3163
|
-
var mapStore;
|
|
3164
|
-
var hasRequiredMapStore;
|
|
3165
|
-
|
|
3166
|
-
function requireMapStore () {
|
|
3167
|
-
if (hasRequiredMapStore) return mapStore;
|
|
3168
|
-
hasRequiredMapStore = 1;
|
|
3169
|
-
|
|
3170
|
-
const path = require$$0$5;
|
|
3171
|
-
const fs = require$$0$2;
|
|
3172
|
-
const debug = requireSrc()('istanbuljs');
|
|
3173
|
-
const { TraceMap, sourceContentFor } = require$$3;
|
|
3174
|
-
const pathutils = requirePathutils();
|
|
3175
|
-
const { SourceMapTransformer } = requireTransformer();
|
|
3176
|
-
|
|
3177
|
-
/**
|
|
3178
|
-
* Tracks source maps for registered files
|
|
3179
|
-
*/
|
|
3180
|
-
class MapStore {
|
|
3181
|
-
/**
|
|
3182
|
-
* @param {Object} opts [opts=undefined] options.
|
|
3183
|
-
* @param {Boolean} opts.verbose [opts.verbose=false] verbose mode
|
|
3184
|
-
* @param {String} opts.baseDir [opts.baseDir=null] alternate base directory
|
|
3185
|
-
* to resolve sourcemap files
|
|
3186
|
-
* @param {Class} opts.SourceStore [opts.SourceStore=Map] class to use for
|
|
3187
|
-
* SourceStore. Must support `get`, `set` and `clear` methods.
|
|
3188
|
-
* @param {Array} opts.sourceStoreOpts [opts.sourceStoreOpts=[]] arguments
|
|
3189
|
-
* to use in the SourceStore constructor.
|
|
3190
|
-
* @constructor
|
|
3191
|
-
*/
|
|
3192
|
-
constructor(opts) {
|
|
3193
|
-
opts = {
|
|
3194
|
-
baseDir: null,
|
|
3195
|
-
verbose: false,
|
|
3196
|
-
SourceStore: Map,
|
|
3197
|
-
sourceStoreOpts: [],
|
|
3198
|
-
...opts
|
|
3199
|
-
};
|
|
3200
|
-
this.baseDir = opts.baseDir;
|
|
3201
|
-
this.verbose = opts.verbose;
|
|
3202
|
-
this.sourceStore = new opts.SourceStore(...opts.sourceStoreOpts);
|
|
3203
|
-
this.data = Object.create(null);
|
|
3204
|
-
this.sourceFinder = this.sourceFinder.bind(this);
|
|
3205
|
-
}
|
|
3206
|
-
|
|
3207
|
-
/**
|
|
3208
|
-
* Registers a source map URL with this store. It makes some input sanity checks
|
|
3209
|
-
* and silently fails on malformed input.
|
|
3210
|
-
* @param transformedFilePath - the file path for which the source map is valid.
|
|
3211
|
-
* This must *exactly* match the path stashed for the coverage object to be
|
|
3212
|
-
* useful.
|
|
3213
|
-
* @param sourceMapUrl - the source map URL, **not** a comment
|
|
3214
|
-
*/
|
|
3215
|
-
registerURL(transformedFilePath, sourceMapUrl) {
|
|
3216
|
-
const d = 'data:';
|
|
3217
|
-
|
|
3218
|
-
if (
|
|
3219
|
-
sourceMapUrl.length > d.length &&
|
|
3220
|
-
sourceMapUrl.substring(0, d.length) === d
|
|
3221
|
-
) {
|
|
3222
|
-
const b64 = 'base64,';
|
|
3223
|
-
const pos = sourceMapUrl.indexOf(b64);
|
|
3224
|
-
if (pos > 0) {
|
|
3225
|
-
this.data[transformedFilePath] = {
|
|
3226
|
-
type: 'encoded',
|
|
3227
|
-
data: sourceMapUrl.substring(pos + b64.length)
|
|
3228
|
-
};
|
|
3229
|
-
} else {
|
|
3230
|
-
debug(`Unable to interpret source map URL: ${sourceMapUrl}`);
|
|
3231
|
-
}
|
|
3232
|
-
|
|
3233
|
-
return;
|
|
3234
|
-
}
|
|
3235
|
-
|
|
3236
|
-
const dir = path.dirname(path.resolve(transformedFilePath));
|
|
3237
|
-
const file = path.resolve(dir, sourceMapUrl);
|
|
3238
|
-
this.data[transformedFilePath] = { type: 'file', data: file };
|
|
3239
|
-
}
|
|
3240
|
-
|
|
3241
|
-
/**
|
|
3242
|
-
* Registers a source map object with this store. Makes some basic sanity checks
|
|
3243
|
-
* and silently fails on malformed input.
|
|
3244
|
-
* @param transformedFilePath - the file path for which the source map is valid
|
|
3245
|
-
* @param sourceMap - the source map object
|
|
3246
|
-
*/
|
|
3247
|
-
registerMap(transformedFilePath, sourceMap) {
|
|
3248
|
-
if (sourceMap && sourceMap.version) {
|
|
3249
|
-
this.data[transformedFilePath] = {
|
|
3250
|
-
type: 'object',
|
|
3251
|
-
data: sourceMap
|
|
3252
|
-
};
|
|
3253
|
-
} else {
|
|
3254
|
-
debug(
|
|
3255
|
-
'Invalid source map object: ' +
|
|
3256
|
-
JSON.stringify(sourceMap, null, 2)
|
|
3257
|
-
);
|
|
3258
|
-
}
|
|
3259
|
-
}
|
|
3260
|
-
|
|
3261
|
-
/**
|
|
3262
|
-
* Retrieve a source map object from this store.
|
|
3263
|
-
* @param filePath - the file path for which the source map is valid
|
|
3264
|
-
* @returns {Object} a parsed source map object
|
|
3265
|
-
*/
|
|
3266
|
-
getSourceMapSync(filePath) {
|
|
3267
|
-
try {
|
|
3268
|
-
if (!this.data[filePath]) {
|
|
3269
|
-
return;
|
|
3270
|
-
}
|
|
3271
|
-
|
|
3272
|
-
const d = this.data[filePath];
|
|
3273
|
-
if (d.type === 'file') {
|
|
3274
|
-
return JSON.parse(fs.readFileSync(d.data, 'utf8'));
|
|
3275
|
-
}
|
|
3276
|
-
|
|
3277
|
-
if (d.type === 'encoded') {
|
|
3278
|
-
return JSON.parse(Buffer.from(d.data, 'base64').toString());
|
|
3279
|
-
}
|
|
3280
|
-
|
|
3281
|
-
/* The caller might delete properties */
|
|
3282
|
-
return {
|
|
3283
|
-
...d.data
|
|
3284
|
-
};
|
|
3285
|
-
} catch (error) {
|
|
3286
|
-
debug('Error returning source map for ' + filePath);
|
|
3287
|
-
debug(error.stack);
|
|
3288
|
-
|
|
3289
|
-
return;
|
|
3290
|
-
}
|
|
3291
|
-
}
|
|
3292
|
-
|
|
3293
|
-
/**
|
|
3294
|
-
* Add inputSourceMap property to coverage data
|
|
3295
|
-
* @param coverageData - the __coverage__ object
|
|
3296
|
-
* @returns {Object} a parsed source map object
|
|
3297
|
-
*/
|
|
3298
|
-
addInputSourceMapsSync(coverageData) {
|
|
3299
|
-
Object.entries(coverageData).forEach(([filePath, data]) => {
|
|
3300
|
-
if (data.inputSourceMap) {
|
|
3301
|
-
return;
|
|
3302
|
-
}
|
|
3303
|
-
|
|
3304
|
-
const sourceMap = this.getSourceMapSync(filePath);
|
|
3305
|
-
if (sourceMap) {
|
|
3306
|
-
data.inputSourceMap = sourceMap;
|
|
3307
|
-
/* This huge property is not needed. */
|
|
3308
|
-
delete data.inputSourceMap.sourcesContent;
|
|
3309
|
-
}
|
|
3310
|
-
});
|
|
3311
|
-
}
|
|
3312
|
-
|
|
3313
|
-
sourceFinder(filePath) {
|
|
3314
|
-
const content = this.sourceStore.get(filePath);
|
|
3315
|
-
if (content !== undefined) {
|
|
3316
|
-
return content;
|
|
3317
|
-
}
|
|
3318
|
-
|
|
3319
|
-
if (path.isAbsolute(filePath)) {
|
|
3320
|
-
return fs.readFileSync(filePath, 'utf8');
|
|
3321
|
-
}
|
|
3322
|
-
|
|
3323
|
-
return fs.readFileSync(
|
|
3324
|
-
pathutils.asAbsolute(filePath, this.baseDir),
|
|
3325
|
-
'utf8'
|
|
3326
|
-
);
|
|
3327
|
-
}
|
|
3328
|
-
|
|
3329
|
-
/**
|
|
3330
|
-
* Transforms the coverage map provided into one that refers to original
|
|
3331
|
-
* sources when valid mappings have been registered with this store.
|
|
3332
|
-
* @param {CoverageMap} coverageMap - the coverage map to transform
|
|
3333
|
-
* @returns {Promise<CoverageMap>} the transformed coverage map
|
|
3334
|
-
*/
|
|
3335
|
-
async transformCoverage(coverageMap) {
|
|
3336
|
-
const hasInputSourceMaps = coverageMap
|
|
3337
|
-
.files()
|
|
3338
|
-
.some(
|
|
3339
|
-
file => coverageMap.fileCoverageFor(file).data.inputSourceMap
|
|
3340
|
-
);
|
|
3341
|
-
|
|
3342
|
-
if (!hasInputSourceMaps && Object.keys(this.data).length === 0) {
|
|
3343
|
-
return coverageMap;
|
|
3344
|
-
}
|
|
3345
|
-
|
|
3346
|
-
const transformer = new SourceMapTransformer(
|
|
3347
|
-
async (filePath, coverage) => {
|
|
3348
|
-
try {
|
|
3349
|
-
const obj =
|
|
3350
|
-
coverage.data.inputSourceMap ||
|
|
3351
|
-
this.getSourceMapSync(filePath);
|
|
3352
|
-
if (!obj) {
|
|
3353
|
-
return null;
|
|
3354
|
-
}
|
|
3355
|
-
|
|
3356
|
-
const smc = new TraceMap(obj);
|
|
3357
|
-
smc.sources.forEach(s => {
|
|
3358
|
-
if (s) {
|
|
3359
|
-
const content = sourceContentFor(smc, s);
|
|
3360
|
-
if (content) {
|
|
3361
|
-
const sourceFilePath = pathutils.relativeTo(
|
|
3362
|
-
s,
|
|
3363
|
-
filePath
|
|
3364
|
-
);
|
|
3365
|
-
this.sourceStore.set(sourceFilePath, content);
|
|
3366
|
-
}
|
|
3367
|
-
}
|
|
3368
|
-
});
|
|
3369
|
-
|
|
3370
|
-
return smc;
|
|
3371
|
-
} catch (error) {
|
|
3372
|
-
debug('Error returning source map for ' + filePath);
|
|
3373
|
-
debug(error.stack);
|
|
3374
|
-
|
|
3375
|
-
return null;
|
|
3376
|
-
}
|
|
3377
|
-
}
|
|
3378
|
-
);
|
|
3379
|
-
|
|
3380
|
-
return await transformer.transform(coverageMap);
|
|
3381
|
-
}
|
|
3382
|
-
|
|
3383
|
-
/**
|
|
3384
|
-
* Disposes temporary resources allocated by this map store
|
|
3385
|
-
*/
|
|
3386
|
-
dispose() {
|
|
3387
|
-
this.sourceStore.clear();
|
|
3388
|
-
}
|
|
3389
|
-
}
|
|
3390
|
-
|
|
3391
|
-
mapStore = { MapStore };
|
|
3392
|
-
return mapStore;
|
|
3393
|
-
}
|
|
3394
|
-
|
|
3395
|
-
/*
|
|
3396
|
-
Copyright 2012-2015, Yahoo Inc.
|
|
3397
|
-
Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms.
|
|
3398
|
-
*/
|
|
3399
|
-
|
|
3400
|
-
var istanbulLibSourceMaps;
|
|
3401
|
-
var hasRequiredIstanbulLibSourceMaps;
|
|
3402
|
-
|
|
3403
|
-
function requireIstanbulLibSourceMaps () {
|
|
3404
|
-
if (hasRequiredIstanbulLibSourceMaps) return istanbulLibSourceMaps;
|
|
3405
|
-
hasRequiredIstanbulLibSourceMaps = 1;
|
|
3406
|
-
|
|
3407
|
-
const { MapStore } = requireMapStore();
|
|
3408
|
-
/**
|
|
3409
|
-
* @module Exports
|
|
3410
|
-
*/
|
|
3411
|
-
istanbulLibSourceMaps = {
|
|
3412
|
-
createSourceMapStore(opts) {
|
|
3413
|
-
return new MapStore(opts);
|
|
3414
|
-
}
|
|
3415
|
-
};
|
|
3416
|
-
return istanbulLibSourceMaps;
|
|
3417
|
-
}
|
|
3418
|
-
|
|
3419
|
-
var istanbulLibSourceMapsExports = requireIstanbulLibSourceMaps();
|
|
3420
|
-
var libSourceMaps = /*@__PURE__*/getDefaultExportFromCjs(istanbulLibSourceMapsExports);
|
|
3421
|
-
|
|
3422
|
-
var version = "5.0.0-rc.2";
|
|
17
|
+
var version = "5.0.0-rc.3";
|
|
3423
18
|
|
|
3424
19
|
const debug = createDebug("vitest:coverage");
|
|
3425
20
|
class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
@@ -3444,7 +39,7 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
|
3444
39
|
ignoreClassMethods: this.options.ignoreClassMethods
|
|
3445
40
|
});
|
|
3446
41
|
} else {
|
|
3447
|
-
this.instrumenter =
|
|
42
|
+
this.instrumenter = createInstrumenter({
|
|
3448
43
|
produceSourceMap: true,
|
|
3449
44
|
autoWrap: false,
|
|
3450
45
|
esModules: true,
|
|
@@ -3453,11 +48,6 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
|
3453
48
|
coverageGlobalScope: "globalThis",
|
|
3454
49
|
coverageGlobalScopeFunc: false,
|
|
3455
50
|
ignoreClassMethods: this.options.ignoreClassMethods,
|
|
3456
|
-
parserPlugins: [...defaults.instrumenter.parserPlugins, ["importAttributes", { deprecatedAssertSyntax: true }]],
|
|
3457
|
-
generatorOpts: {
|
|
3458
|
-
// @ts-expect-error missing type
|
|
3459
|
-
importAttributesKeyword: "with" },
|
|
3460
|
-
// Custom option from the patched istanbul-lib-instrument: https://github.com/istanbuljs/istanbuljs/pull/835
|
|
3461
51
|
ignoreLines: true
|
|
3462
52
|
});
|
|
3463
53
|
}
|
|
@@ -3513,7 +103,7 @@ importAttributesKeyword: "with" },
|
|
|
3513
103
|
};
|
|
3514
104
|
}
|
|
3515
105
|
createCoverageMap() {
|
|
3516
|
-
return
|
|
106
|
+
return libCoverage.createCoverageMap({});
|
|
3517
107
|
}
|
|
3518
108
|
async generateCoverage({ allTestsRun }) {
|
|
3519
109
|
const start = debug.enabled ? performance.now() : 0;
|
|
@@ -3562,11 +152,12 @@ importAttributesKeyword: "with" },
|
|
|
3562
152
|
}
|
|
3563
153
|
for (const reporter of this.options.reporter) {
|
|
3564
154
|
// Type assertion required for custom reporters
|
|
3565
|
-
|
|
155
|
+
const reportInstance = await libReport.createAsync(reporter[0], {
|
|
3566
156
|
skipFull: this.options.skipFull,
|
|
3567
157
|
projectRoot: this.ctx.config.root,
|
|
3568
158
|
...reporter[1]
|
|
3569
|
-
})
|
|
159
|
+
});
|
|
160
|
+
reportInstance.execute(context);
|
|
3570
161
|
}
|
|
3571
162
|
if (this.options.thresholds) {
|
|
3572
163
|
await this.reportThresholds(coverageMap, allTestsRun);
|