MCPcopy Create free account
hub / github.com/NomicFoundation/hardhat / parsePatterns

Function parsePatterns

packages/hardhat-utils/src/internal/debug.ts:23–45  ·  view source on GitHub ↗
(env: string)

Source from the content-addressed store, hash-verified

21 * `createDebug` is called many times at startup.
22 */
23export function parsePatterns(env: string): ParsedPatterns {
24 if (cached !== undefined && cached.env === env) {
25 return cached.parsed;
26 }
27
28 const include: RegExp[] = [];
29 const exclude: RegExp[] = [];
30
31 for (const raw of env.split(/[\s,]+/)) {
32 if (raw === "") {
33 continue;
34 }
35 if (raw.startsWith("-")) {
36 exclude.push(namespaceToRegExp(raw.slice(1)));
37 } else {
38 include.push(namespaceToRegExp(raw));
39 }
40 }
41
42 const parsed: ParsedPatterns = { include, exclude };
43 cached = { env, parsed };
44 return parsed;
45}
46
47/**
48 * Converts a `DEBUG`-style namespace pattern into an anchored regex.

Callers 2

debug.tsFile · 0.85
isEnabledFunction · 0.85

Calls 1

namespaceToRegExpFunction · 0.85

Tested by

no test coverage detected