MCPcopy Index your code
hub / github.com/webpack/css-loader / removeCWD

Function removeCWD

test/helpers/normalizeErrors.js:3–28  ·  view source on GitHub ↗
(str)

Source from the content-addressed store, hash-verified

1import stripAnsi from "strip-ansi";
2
3export function removeCWD(str) {
4 const isWin = process.platform === "win32";
5 let cwd = process.cwd();
6
7 if (isWin) {
8 if (str.split("\n").length > 3) {
9 // @import '\
10 // \
11 // \
12 // ';
13
14 return stripAnsi(str)
15 .replace(/\(from .*?\)/, "(from `replaced original path`)")
16 .replace(new RegExp(cwd, "g"), "");
17 }
18
19 // eslint-disable-next-line no-param-reassign
20 str = str.replace(/\\/g, "/");
21 // eslint-disable-next-line no-param-reassign
22 cwd = cwd.replace(/\\/g, "/");
23 }
24
25 return stripAnsi(str)
26 .replace(/\(from .*?\)/, "(from `replaced original path`)")
27 .replace(new RegExp(cwd, "g"), "");
28}
29
30export default (errors, shortError, type) =>
31 errors.map((error) => {

Callers 2

normalizeErrors.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…