-
Notifications
You must be signed in to change notification settings - Fork 128
/
default.js
46 lines (41 loc) · 1.28 KB
/
default.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
var util = require('util');
var chalk = require('chalk');
var BaseReporter = require('./base');
class DefaultReporter extends BaseReporter {
/**
* The default reporter, which displays both file and line information for
* each given match.
*
* @constructor
*
* @param {Inspector} inspector Instance on which to register its listeners
* @param {object} opts Options to set for the reporter
*/
constructor(inspector, opts) {
opts = opts || {};
super(inspector, opts);
this._registerSummary();
}
/**
* Returns the string output to print for the given reporter. The string
* contains the number of instances associated with the match and the files
* and lines involved.
*
* @private
*
* @param {Match} match The inspector match to output
* @returns {string} The formatted output
*/
_getOutput(match) {
var instances = match.instances;
var output = '\n' + '-'.repeat(60) + '\n\n' +
chalk.bold(`Match - ${instances.length} instances\n`);
instances.forEach((instance) => {
var location = this._getFormattedLocation(instance);
var lines = this._getLines(instance);
output += `\n${location}\n${chalk.grey(lines)}\n`;
});
return output;
}
}
module.exports = DefaultReporter;