source: trip-planner-front/node_modules/webpack/lib/ErrorHelpers.js@ fa375fe

Last change on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.4 KB
RevLine 
[6a3a178]1/*
2 MIT License http://www.opensource.org/licenses/mit-license.php
3 Author Tobias Koppers @sokra
4*/
5
6"use strict";
7
8const loaderFlag = "LOADER_EXECUTION";
9
10const webpackOptionsFlag = "WEBPACK_OPTIONS";
11
12exports.cutOffByFlag = (stack, flag) => {
13 stack = stack.split("\n");
14 for (let i = 0; i < stack.length; i++) {
15 if (stack[i].includes(flag)) {
16 stack.length = i;
17 }
18 }
19 return stack.join("\n");
20};
21
22exports.cutOffLoaderExecution = stack =>
23 exports.cutOffByFlag(stack, loaderFlag);
24
25exports.cutOffWebpackOptions = stack =>
26 exports.cutOffByFlag(stack, webpackOptionsFlag);
27
28exports.cutOffMultilineMessage = (stack, message) => {
29 stack = stack.split("\n");
30 message = message.split("\n");
31
32 const result = [];
33
34 stack.forEach((line, idx) => {
35 if (!line.includes(message[idx])) result.push(line);
36 });
37
38 return result.join("\n");
39};
40
41exports.cutOffMessage = (stack, message) => {
42 const nextLine = stack.indexOf("\n");
43 if (nextLine === -1) {
44 return stack === message ? "" : stack;
45 } else {
46 const firstLine = stack.substr(0, nextLine);
47 return firstLine === message ? stack.substr(nextLine + 1) : stack;
48 }
49};
50
51exports.cleanUp = (stack, message) => {
52 stack = exports.cutOffLoaderExecution(stack);
53 stack = exports.cutOffMessage(stack, message);
54 return stack;
55};
56
57exports.cleanUpWebpackOptions = (stack, message) => {
58 stack = exports.cutOffWebpackOptions(stack);
59 stack = exports.cutOffMultilineMessage(stack, message);
60 return stack;
61};
Note: See TracBrowser for help on using the repository browser.