UNPKG

1.33 kBJavaScriptView Raw
1"use strict";
2var __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};
9Object.defineProperty(exports, "__esModule", { value: true });
10const code_frame_1 = require("@babel/code-frame");
11const fs = __importStar(require("fs"));
12const os = __importStar(require("os"));
13const env_1 = require("../util/env");
14function 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}
36exports.formatTsLoaderMessages = formatTsLoaderMessages;
37//# sourceMappingURL=formatTsLoaderMessages.js.map
\No newline at end of file