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 | exports.normalizePath = exports.color = exports.insertLoader = exports.findLoader = void 0;
|
7 | const path_1 = __importDefault(require("path"));
|
8 |
|
9 |
|
10 |
|
11 | const findLoader = (useArray, loaderNamesRegex) => {
|
12 | const index = useArray.findIndex((loaderObject) => {
|
13 | let loaderName = '';
|
14 | if (typeof loaderObject === 'string') {
|
15 | loaderName = loaderObject;
|
16 | }
|
17 | else if ('loader' in loaderObject &&
|
18 | typeof loaderObject.loader === 'string') {
|
19 | loaderName = loaderObject.loader;
|
20 | }
|
21 | return loaderNamesRegex.exec(loaderName) !== null;
|
22 | });
|
23 | return index === -1 ? undefined : index;
|
24 | };
|
25 | exports.findLoader = findLoader;
|
26 |
|
27 |
|
28 |
|
29 | const insertLoader = (useArray, index, loader) => {
|
30 | if (index === undefined) {
|
31 | return;
|
32 | }
|
33 | useArray.splice(index, 0, loader);
|
34 | };
|
35 | exports.insertLoader = insertLoader;
|
36 |
|
37 |
|
38 |
|
39 | const normalizePath = (resourcePath, rootContext) => {
|
40 | const relativePath = resourcePath.replace(path_1.default.normalize(rootContext), '');
|
41 | const normalizedPath = relativePath.split(path_1.default.sep).join('/');
|
42 | return normalizedPath;
|
43 | };
|
44 | exports.normalizePath = normalizePath;
|
45 | const color = {
|
46 | Reset: '\u001B[0m',
|
47 | Bright: '\u001B[1m',
|
48 | Dim: '\u001B[2m',
|
49 | Underscore: '\u001B[4m',
|
50 | Blink: '\u001B[5m',
|
51 | Reverse: '\u001B[7m',
|
52 | Hidden: '\u001B[8m',
|
53 | FgBlack: '\u001B[30m',
|
54 | FgRed: '\u001B[31m',
|
55 | FgGreen: '\u001B[32m',
|
56 | FgYellow: '\u001B[33m',
|
57 | FgBlue: '\u001B[34m',
|
58 | FgMagenta: '\u001B[35m',
|
59 | FgCyan: '\u001B[36m',
|
60 | FgWhite: '\u001B[37m',
|
61 | BgBlack: '\u001B[40m',
|
62 | BgRed: '\u001B[41m',
|
63 | BgGreen: '\u001B[42m',
|
64 | BgYellow: '\u001B[43m',
|
65 | BgBlue: '\u001B[44m',
|
66 | BgMagenta: '\u001B[45m',
|
67 | BgCyan: '\u001B[46m',
|
68 | BgWhite: '\u001B[47m',
|
69 | };
|
70 | exports.color = color;
|