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