|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 13 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.2 KB
|
| Line | |
|---|
| 1 | "use strict";
|
|---|
| 2 | var __importDefault = (this && this.__importDefault) || function (mod) {
|
|---|
| 3 | return (mod && mod.__esModule) ? mod : { "default": mod };
|
|---|
| 4 | };
|
|---|
| 5 | Object.defineProperty(exports, "__esModule", { value: true });
|
|---|
| 6 | const os_1 = __importDefault(require("os"));
|
|---|
| 7 | const fs_extra_1 = __importDefault(require("fs-extra"));
|
|---|
| 8 | const code_frame_1 = require("@babel/code-frame");
|
|---|
| 9 | const BasicFormatter_1 = require("./BasicFormatter");
|
|---|
| 10 | function createCodeFrameFormatter(options) {
|
|---|
| 11 | const basicFormatter = BasicFormatter_1.createBasicFormatter();
|
|---|
| 12 | return function codeFrameFormatter(issue) {
|
|---|
| 13 | const source = issue.file && fs_extra_1.default.existsSync(issue.file) && fs_extra_1.default.readFileSync(issue.file, 'utf-8');
|
|---|
| 14 | let frame = '';
|
|---|
| 15 | if (source && issue.location) {
|
|---|
| 16 | frame = code_frame_1.codeFrameColumns(source, issue.location, Object.assign({ highlightCode: true }, (options || {})))
|
|---|
| 17 | .split('\n')
|
|---|
| 18 | .map((line) => ' ' + line)
|
|---|
| 19 | .join(os_1.default.EOL);
|
|---|
| 20 | }
|
|---|
| 21 | const lines = [basicFormatter(issue)];
|
|---|
| 22 | if (frame) {
|
|---|
| 23 | lines.push(frame);
|
|---|
| 24 | }
|
|---|
| 25 | return lines.join(os_1.default.EOL);
|
|---|
| 26 | };
|
|---|
| 27 | }
|
|---|
| 28 | exports.createCodeFrameFormatter = createCodeFrameFormatter;
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.