globby
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
@sindresorhus/merge-streams | 1.0.0 | 1.87 kB | MIT | prod | |
fast-glob | 3.3.2 | 24.37 kB | MIT | prod | |
ignore | 5.3.1 | 14.1 kB | MIT | prod | |
path-type | 5.0.0 | 2.14 kB | MIT | prod | |
slash | 5.1.0 | 1.65 kB | MIT | prod | |
unicorn-magic | 0.1.0 | 1.86 kB | MIT | prod |
Globby is a user-friendly glob matching utility for JavaScript, built on top of the fast-glob
library. It provides a more feature-rich interface for matching files and directories using globbing patterns. Its main features include a Promise-based API, support for multiple and negated patterns, the ability to expand directories in patterns, and the option to respect ignore patterns in .gitignore
and similar files. Furthermore, it supports URL
as cwd
.
Globby can be installed using npm with the command $ npm install globby
. Once installed, it can be imported and used in your JavaScript code. Here's how you can use Globby to match file paths:
import {globby} from 'globby';
// Find all files in the current directory, excluding 'cake'
const paths = await globby(['*', '!cake']);
console.log(paths);
//=> ['unicorn', 'rainbow']
In this example, the globby
function is called with an array containing two patterns, '*'
and '!cake'
. The asterisk (*
) matches any file or directory, while prefixing a pattern with an exclamation mark (!
) negates it, excluding any matches from the results.
It's important to note that glob patterns should only contain forward-slashes, not backward-slashes. If you need to construct a glob pattern from path components, use path.posix.join()
instead of path.join()
.
Documentation for Globby can be found directly in the readme file located in the repository on GitHub. This file provides a comprehensive guide to the utility’s API and usage, including details of the function signatures, available options, return types, as well as a number of usage examples. Additionally, there are links to supporting libraries used by Globby, such as fast-glob
and minimatch
, where further details and context can be found.