MCPcopy Create free account
hub / github.com/webpack/webpack-cli / normalizeStderr

Function normalizeStderr

test/utils/test-utils.js:273–320  ·  view source on GitHub ↗
(stderr)

Source from the content-addressed store, hash-verified

271const IPV6 = /([0-9a-f]){1,4}(:([0-9a-f]){1,4}){7}/gi;
272
273const normalizeStderr = (stderr) => {
274 if (typeof stderr !== "string") {
275 return stderr;
276 }
277
278 if (stderr.length === 0) {
279 return stderr;
280 }
281
282 let normalizedStderr = stripVTControlCharacters(stderr);
283 normalizedStderr = normalizeCwd(normalizedStderr);
284
285 normalizedStderr = normalizedStderr.replaceAll(IPV4, "x.x.x.x");
286 normalizedStderr = normalizedStderr.replaceAll(IPV6, "[x:x:x:x:x:x:x:x]");
287 normalizedStderr = normalizedStderr.replaceAll(/:[0-9]+\//g, ":<port>/");
288
289 if (!/On Your Network \(IPv6\)/.test(stderr)) {
290 // Github Actions doesn't' support IPv6 on ubuntu in some cases
291 normalizedStderr = normalizedStderr.split("\n");
292
293 const ipv4MessageIndex = normalizedStderr.findIndex((item) =>
294 /On Your Network \(IPv4\)/.test(item),
295 );
296
297 if (ipv4MessageIndex !== -1) {
298 normalizedStderr.splice(
299 ipv4MessageIndex + 1,
300 0,
301 "<i> [webpack-dev-server] On Your Network (IPv6): http://[x:x:x:x:x:x:x:x]:<port>/",
302 );
303 }
304
305 normalizedStderr = normalizedStderr.join("\n");
306 }
307
308 // the warning below is causing CI failure on some jobs
309 if (/Gracefully shutting down/.test(stderr)) {
310 normalizedStderr = normalizedStderr.replace(
311 "\n<i> [webpack-dev-server] Gracefully shutting down. To force exit, press ^C again. Please wait...",
312 "",
313 );
314 }
315
316 normalizedStderr = normalizeVersions(normalizedStderr);
317 normalizedStderr = normalizeError(normalizedStderr);
318
319 return normalizedStderr;
320};
321
322const getWebpackCliArguments = (startWith) => {
323 if (typeof startWith === "undefined") {

Calls 3

normalizeCwdFunction · 0.85
normalizeVersionsFunction · 0.85
normalizeErrorFunction · 0.85

Tested by

no test coverage detected