保誠-保戶業務員媒合平台
tomasysh
2022-05-25 43d0eed31f4b2a59e23c06ceba3616aac3f549f6
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const os_1 = __importDefault(require("os"));
const chalk_1 = __importDefault(require("chalk"));
const path_1 = __importDefault(require("path"));
const issue_1 = require("../issue");
const forwardSlash_1 = __importDefault(require("../utils/path/forwardSlash"));
function createWebpackFormatter(formatter) {
    // mimics webpack error formatter
    return function webpackFormatter(issue) {
        const color = issue.severity === 'warning' ? chalk_1.default.yellow.bold : chalk_1.default.red.bold;
        const severity = issue.severity.toUpperCase();
        if (issue.file) {
            let location = forwardSlash_1.default(path_1.default.relative(process.cwd(), issue.file));
            if (issue.location) {
                location += `:${issue_1.formatIssueLocation(issue.location)}`;
            }
            return [color(`${severity} in ${location}`), formatter(issue), ''].join(os_1.default.EOL);
        }
        else {
            return [color(`${severity} in `) + formatter(issue), ''].join(os_1.default.EOL);
        }
    };
}
exports.createWebpackFormatter = createWebpackFormatter;