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