-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
87 lines (65 loc) · 2.35 KB
/
index.js
File metadata and controls
87 lines (65 loc) · 2.35 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
var tsm = require('teamcity-service-messages');
var messagesByFile = {};
var REPORTER = 'Stylint';
var NEW_LINE = '\n';
// return messages as string instead of printing to stdout
tsm.stdout = false;
/**
* @description format output message for console (default)
* @param {String} message error msg from one of the checks
* @param {String} done whether or not this is the last message to output
* @return {String | Function} either the formatted msg or done()
*/
module.exports = function (message, done) {
var cache = this.cache;
var options = this.config.reporterOptions || {};
if (done === 'done') {
var report = [];
report.push(
tsm.testSuiteStarted({name: REPORTER})
);
var files = Object.keys(messagesByFile);
files.forEach(function(file) {
var fileErrors = messagesByFile[file];
report.push(tsm.testSuiteStarted({name: file}));
fileErrors.forEach(function(error) {
var errorName = error.rule;
report.push(
tsm.testStarted({ name: errorName }),
tsm.testFailed({
name: errorName,
message: error.message,
detailed: error.detailed
}),
tsm.testFinished({ name: errorName })
);
});
report.push(tsm.testSuiteFinished({name: file}));
});
// If there were no errors, tell TeamCity that tests ran successfully
if (files.length === 0) {
report.push(
tsm.testStarted({ name: REPORTER}),
tsm.testFinished({ name: REPORTER})
);
}
report.push(
tsm.testSuiteFinished({name: REPORTER})
);
this.cache.msg = report.join(NEW_LINE);
return this.done();
}
var file = cache.file;
var reportSeverity = (options.reportSeverity || 'all').toLowerCase();
if (reportSeverity !== 'all') {
var severity = this.state.severity.toLowerCase();
if (severity !== reportSeverity ) return '';
}
messagesByFile[file] || (messagesByFile[file] = []);
messagesByFile[file].push({
rule: cache.rule,
message: message,
detailed: message + ' at line ' + cache.lineNo
});
return '';
};