UNPKG

1.09 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 fs = tslib_1.__importStar(require("fs"));
6const os = tslib_1.__importStar(require("os"));
7const env_1 = require("../util/env");
8function 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}
30exports.formatTsLoaderMessages = formatTsLoaderMessages;
31//# sourceMappingURL=formatTsLoaderMessages.js.map
\No newline at end of file