UNPKG

1.25 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const tslib_1 = require("tslib");
4const code_frame_1 = require("@babel/code-frame");
5const chalk_1 = tslib_1.__importDefault(require("chalk"));
6const fs = tslib_1.__importStar(require("fs"));
7const os = tslib_1.__importStar(require("os"));
8const env_1 = require("../util/env");
9function 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}
32exports.formatForkTsCheckerMessages = formatForkTsCheckerMessages;
33//# sourceMappingURL=formatForkTsCheckerMessages.js.map
\No newline at end of file