MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / Skip

Function Skip

src/sidebarApps/searchInFiles/worker.js:269–296  ·  view source on GitHub ↗

* Creates a skip function that filters files based on exclusion and inclusion patterns. * * @param {object} arg - The exclusion patterns separated by commas. * @param {string} arg.exclude - The exclusion patterns separated by commas. * @param {string} arg.include - The inclusion patterns separat

({ exclude, include })

Source from the content-addressed store, hash-verified

267 * @param {string} arg.include - The inclusion patterns separated by commas.
268 */
269function Skip({ exclude, include }) {
270 const userExcludes = (exclude ? exclude.split(",") : [])
271 .map((p) => p.trim())
272 .filter(Boolean);
273 const excludeFiles = userExcludes;
274 const includeFiles = (include ? include.split(",") : ["**"]).map((p) =>
275 p.trim(),
276 );
277
278 /**
279 * Tests whether a file should be skipped based on exclusion and inclusion patterns.
280 *
281 * @param {object} file - The file to be tested.
282 * @param {string} file.path - The relative URL of the file.
283 * @returns {boolean} - Returns true if the file should be skipped, false otherwise.
284 */
285 function test(file) {
286 if (!file.path) return false;
287 if (isBinaryFile(file)) return true;
288 const match = (pattern) =>
289 picomatch.isMatch(file.path, pattern, { matchBase: true });
290 return excludeFiles.some(match) || !includeFiles.some(match);
291 }
292
293 return {
294 test,
295 };
296}
297
298/**
299 * @typedef {Object} Match

Callers 1

processFilesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected