Lightweight, clearly-defined alternative to file glob strings
MIT License
Lightweight, clearly-defined alternative to file glob strings
File globs like ./src/**/*.js
are great... until you get to know them.
**
and *
differs depending on the library or context (for instance, bash treats **/*
differently depending on if the globstar option is set, but the globstar option isn't available in older versions of bash)./package.json
could refer to lots of different files depending on what the current working directory is when the library parses files.
in their results by default, but others don't**/*
, and others don't.
src
means src/**/*
, but in bash, src
only means src
.If you work with glob strings a lot, this kind of stuff starts to bite you over and over, and it gets old. Despite their prevalence, glob strings are far from standardized.
This is particularly annoying when you consider that for 90% of projects, they only care about a particular subset of glob syntax, but we're using these huge globbing libraries despite that.
So, this library provides a way to find files on disk that match a particular pattern, but it doesn't use glob strings. This makes it:
.and
, .andNot
, .or
, and .inverse
)Here's a taste of what it looks like:
// Instead of this:
import fastGlob from "fast-glob";
const filePaths = await fastGlob([
"**/*.ts",
"!**/*.d.ts",
"!node_modules/**/*",
]);
// You do this:
import glomp from "glomp";
const filePaths = await glomp
.withExtension(".ts")
.excludeExtension(".d.ts")
.excludeDir("node_modules")
.findMatches(process.cwd());
Please see api/index.d.ts for API documentation. There are lots of comments.
MIT