📂
File System15M+/wkMIT

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
npm install globby
yarn
yarn add globby
pnpm
pnpm add globby

Import

ESM
import { globby } from 'globby';

Quick Example

usage
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

Packageglobby
CategoryFile System
Weekly Downloads15M+
LicenseMIT
Installnpm install globby

Related Packages

Browse npm Packages by Category

Explore our reference of 200 popular npm packages with install commands, examples, and quick-start guides.