globby
Globby is a user-friendly glob matching library built on top of fast-glob that provides a convenient API for finding files and directories using glob patterns. …
Installation
npm install globby
yarn add globby
pnpm add globby
Import
import { globby } from 'globby';Quick Example
import { globby } from 'globby';
const files = await globby([
'src/**/*.ts',
'!src/**/*.test.ts',
'!src/**/*.spec.ts',
]);
const withGitignore = await globby('**/*.js', {
gitignore: true,
});About globby
Globby is a user-friendly glob matching library built on top of fast-glob that provides a convenient API for finding files and directories using glob patterns. Globby improves upon the standard glob library with support for multiple patterns in a single call, negation patterns prefixed with ! for excluding files, expandDirectories for automatically adding /** to directory paths, gitignore integration for automatically respecting .gitignore rules, and returning absolute paths. The library provides both async (globby()) and sync (globbySync()) APIs, along with stream (globbyStream()) for processing large directory trees without loading all paths into memory. Globby handles brace expansion ({a,b}), character classes ([abc]), globstar (**) for recursive matching, and question marks (?) for single character matching. The isDynamicPattern utility helps determine if a pattern contains glob characters. Globby is used by many popular tools including ESLint, Prettier, lint-staged, and various CLI applications for file discovery. The library provides a cleaner API than fast-glob for most use cases while maintaining the same high performance. For simple cases, fast-glob may be preferred for its lighter weight, but Globby's negation patterns and gitignore support make it more practical for most applications.
Quick Facts
| Package | globby |
| Category | File System |
| Weekly Downloads | 15M+ |
| License | MIT |
| Install | npm install globby |
Related Packages
fast-glob is a high-performance glob matching library for Node.js that provides significant speed im…
glob is a library for matching files using glob patterns — the wildcard syntax familiar from shell c…
minimatch is a minimal matching utility that tests whether a filename or path string matches a given…
rimraf is a Node.js implementation of the Unix rm -rf command, providing cross-platform recursive di…
Browse npm Packages by Category
Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.