UNPKG

fs-visitor

Version:

A Node.js library for recursively listing files and directories with customizable filtering and sorting options.

15 lines (14 loc) 530 B
// src/filter.ts import { minimatch } from "minimatch"; var createFileEntry = ({ include = [], exclude = [] }) => { const includeList = Array.isArray(include) ? include : [include]; const excludeList = Array.isArray(exclude) ? exclude : [exclude]; return (entry) => { const isIncluded = includeList.some((pattern) => minimatch(entry.relative, pattern)); const isExcluded = excludeList.some((pattern) => minimatch(entry.relative, pattern)); return isIncluded && !isExcluded; }; }; export { createFileEntry };