MCPcopy Index your code
hub / github.com/nodejs/node / createIgnoreMatcher

Function createIgnoreMatcher

lib/internal/fs/watchers.js:89–124  ·  view source on GitHub ↗

* Creates an ignore matcher function from the ignore option. * @param {string | RegExp | Function | Array} ignore - The ignore patterns * @returns {Function | null} A function that returns true if filename should be ignored

(ignore)

Source from the content-addressed store, hash-verified

87 * @returns {Function | null} A function that returns true if filename should be ignored
88 */
89function createIgnoreMatcher(ignore) {
90 if (ignore == null) return null;
91 const matchers = ArrayIsArray(ignore) ? ignore : [ignore];
92 const compiled = [];
93
94 for (let i = 0; i < matchers.length; i++) {
95 const matcher = matchers[i];
96 if (typeof matcher === 'string') {
97 const mm = new (lazyMinimatch().Minimatch)(matcher, {
98 __proto__: null,
99 nocase: isWindows || isMacOS,
100 windowsPathsNoEscape: true,
101 nonegate: true,
102 nocomment: true,
103 optimizationLevel: 2,
104 platform: process.platform,
105 // matchBase allows patterns without slashes to match the basename
106 // e.g., '*.log' matches 'subdir/file.log'
107 matchBase: true,
108 });
109 ArrayPrototypePush(compiled, (filename) => mm.match(filename));
110 } else if (isRegExp(matcher)) {
111 ArrayPrototypePush(compiled, (filename) => RegExpPrototypeExec(matcher, filename) !== null);
112 } else {
113 // Function
114 ArrayPrototypePush(compiled, matcher);
115 }
116 }
117
118 return (filename) => {
119 for (let i = 0; i < compiled.length; i++) {
120 if (compiled[i](filename)) return true;
121 }
122 return false;
123 };
124}
125
126function emitStop(self) {
127 self.emit('stop');

Callers 3

constructorMethod · 0.85
watchers.jsFile · 0.85
watchFunction · 0.85

Calls 2

lazyMinimatchFunction · 0.85
matchMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…