1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const tslib_1 = require("tslib");
|
4 | const code_frame_1 = require("@babel/code-frame");
|
5 | const chalk_1 = tslib_1.__importDefault(require("chalk"));
|
6 | const fs = tslib_1.__importStar(require("fs"));
|
7 | const os = tslib_1.__importStar(require("os"));
|
8 | const env_1 = require("../util/env");
|
9 | function formatForkTsCheckerMessages(error, useColors) {
|
10 | const colors = new chalk_1.default.constructor({ enabled: useColors });
|
11 | const { file } = error;
|
12 | const source = file && fs.existsSync(file) && fs.readFileSync(file, 'utf-8');
|
13 | if (source) {
|
14 | const frame = code_frame_1.codeFrameColumns(source, {
|
15 | start: {
|
16 | line: error.line,
|
17 | column: error.character,
|
18 | },
|
19 | }, {
|
20 | highlightCode: env_1.IS_INTERACTIVE && !env_1.IS_CI,
|
21 | });
|
22 | return (colors.dim(`${error.line}:${error.character} `) +
|
23 | error.content +
|
24 | colors.cyan(` (TS${error.code})`) +
|
25 | os.EOL +
|
26 | (frame ? os.EOL + frame : ''));
|
27 | }
|
28 | else {
|
29 | return '';
|
30 | }
|
31 | }
|
32 | exports.formatForkTsCheckerMessages = formatForkTsCheckerMessages;
|
33 |
|
\ | No newline at end of file |