UNPKG

1.61 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5var __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};
12Object.defineProperty(exports, "__esModule", { value: true });
13const code_frame_1 = require("@babel/code-frame");
14const chalk_1 = __importDefault(require("chalk"));
15const fs = __importStar(require("fs"));
16const os = __importStar(require("os"));
17const env_1 = require("../util/env");
18function 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}
41exports.formatForkTsCheckerMessages = formatForkTsCheckerMessages;
42//# sourceMappingURL=formatForkTsCheckerMessages.js.map
\No newline at end of file