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 fs = tslib_1.__importStar(require("fs"));
|
6 | const os = tslib_1.__importStar(require("os"));
|
7 | const env_1 = require("../util/env");
|
8 | function formatTsLoaderMessages(error, colors) {
|
9 | const { file } = error;
|
10 | const source = file && fs.existsSync(file) && fs.readFileSync(file, 'utf-8');
|
11 | if (source) {
|
12 | const frame = code_frame_1.codeFrameColumns(source, {
|
13 | start: {
|
14 | line: error.line,
|
15 | column: error.character,
|
16 | },
|
17 | }, {
|
18 | highlightCode: env_1.IS_INTERACTIVE && !env_1.IS_CI,
|
19 | });
|
20 | return (colors.dim(`${error.line}:${error.character} `) +
|
21 | error.content +
|
22 | colors.cyan(` (TS${error.code})`) +
|
23 | os.EOL +
|
24 | (frame ? os.EOL + frame : ''));
|
25 | }
|
26 | else {
|
27 | return '';
|
28 | }
|
29 | }
|
30 | exports.formatTsLoaderMessages = formatTsLoaderMessages;
|
31 |
|
\ | No newline at end of file |