1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const chalk_1 = require("chalk");
|
4 | const os = require("os");
|
5 | const NormalizedMessage_1 = require("../NormalizedMessage");
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | function createDefaultFormatter() {
|
12 | return function defaultFormatter(message, useColors) {
|
13 | const colors = new chalk_1.default.constructor({ enabled: useColors });
|
14 | const messageColor = message.isWarningSeverity()
|
15 | ? colors.bold.yellow
|
16 | : colors.bold.red;
|
17 | const fileAndNumberColor = colors.bold.cyan;
|
18 | const codeColor = colors.grey;
|
19 | if (message.code === NormalizedMessage_1.NormalizedMessage.ERROR_CODE_INTERNAL) {
|
20 | return (messageColor(`INTERNAL ${message.severity.toUpperCase()}: `) +
|
21 | message.content +
|
22 | (message.stack
|
23 | ? os.EOL + 'stack trace:' + os.EOL + colors.gray(message.stack)
|
24 | : ''));
|
25 | }
|
26 | return [
|
27 | messageColor(`${message.severity.toUpperCase()} in `) +
|
28 | fileAndNumberColor(`${message.file}(${message.line},${message.character})`) +
|
29 | messageColor(':'),
|
30 | codeColor(message.getFormattedCode() + ': ') + message.content
|
31 | ].join(os.EOL);
|
32 | };
|
33 | }
|
34 | exports.createDefaultFormatter = createDefaultFormatter;
|
35 |
|
\ | No newline at end of file |