constatic
Version:
Constatic is a CLI for creating and managing modern TypeScript projects, providing an organized structure and features that streamline development.
16 lines (15 loc) • 583 B
JavaScript
// src/lib/glob.ts
import { glob as nodeGlob } from "node:fs/promises";
import { resolve } from "node:path";
async function glob(patterns, options = {}) {
const exclude = Array.isArray(patterns) ? patterns.filter((p) => p.charAt(0) === "!") : [];
const include = Array.isArray(patterns) ? patterns.filter((p) => p.charAt(0) !== "!") : patterns;
if (exclude.length >= 1) {
Object.assign(options, { exclude });
}
const paths = await Array.fromAsync(nodeGlob(include, options));
return options.absolute ? paths.map((path) => resolve(path)) : paths;
}
export {
glob
};