* 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)
| 87 | * @returns {Function | null} A function that returns true if filename should be ignored |
| 88 | */ |
| 89 | function 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 | |
| 126 | function emitStop(self) { |
| 127 | self.emit('stop'); |
no test coverage detected
searching dependent graphs…