### Install globby Source: https://github.com/sindresorhus/globby/blob/main/readme.md Installs the globby package using npm. This is the first step to using globby in your Node.js project. ```sh npm install globby ``` -------------------------------- ### Expand directories with globby Source: https://github.com/sindresorhus/globby/blob/main/readme.md Shows how to use the `expandDirectories` option in globby. This example expands the 'images' directory and filters by specific file patterns and extensions. ```javascript import {globby} from 'globby'; const paths = await globby('images', { expandDirectories: { files: ['cat', 'unicorn', '*.jpg'], extensions: ['png'] } }); console.log(paths); //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg'] ``` -------------------------------- ### Basic globby usage Source: https://github.com/sindresorhus/globby/blob/main/readme.md Demonstrates the basic usage of globby to find files. It uses a Promise API to asynchronously return an array of matching file paths, excluding 'cake'. ```javascript import {globby} from 'globby'; const paths = await globby(['*', '!cake']); console.log(paths); //=> ['unicorn', 'rainbow'] ``` -------------------------------- ### Stream glob matches with globbyStream Source: https://github.com/sindresorhus/globby/blob/main/readme.md Illustrates using `globbyStream` to process glob matches as a readable stream. This is useful for handling large numbers of files efficiently using async iteration. ```javascript import {globbyStream} from 'globby'; for await (const path of globbyStream('*.tmp')) { console.log(path); } ``` -------------------------------- ### Check if path is ignored by ignore files (Async) Source: https://github.com/sindresorhus/globby/blob/main/readme.md The `isIgnoredByIgnoreFiles` function returns a promise that resolves to a boolean indicating if a path is ignored by ignore files. It's a generic version of `isGitIgnored` and supports ignore files with compatible syntax, such as `.babelignore` or `.prettierignore`. It takes an optional `cwd` option. ```JavaScript import {isIgnoredByIgnoreFiles} from 'globby'; const isIgnored = await isIgnoredByIgnoreFiles("**/.gitignore"); console.log(isIgnored('some/file')); ``` -------------------------------- ### Check if path is git ignored with isGitIgnored Source: https://github.com/sindresorhus/globby/blob/main/readme.md Demonstrates how to use `isGitIgnored` to check if a file path is ignored by Git. It returns a promise that resolves to a function which takes a path and returns a boolean. ```javascript import {isGitIgnored} from 'globby'; const isIgnored = await isGitIgnored(); console.log(isIgnored('some/file')); ``` -------------------------------- ### Check if path is ignored by ignore files (Sync) Source: https://github.com/sindresorhus/globby/blob/main/readme.md The `isIgnoredByIgnoreFilesSync` function returns a boolean indicating if a path is ignored by ignore files. It's the synchronous counterpart to `isIgnoredByIgnoreFiles` and supports ignore files with compatible syntax, such as `.babelignore` or `.prettierignore`. It takes an optional `cwd` option. ```JavaScript import {isIgnoredByIgnoreFilesSync} from 'globby'; const isIgnored = isIgnoredByIgnoreFilesSync("**/.gitignore"); console.log(isIgnored('some/file')); ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.