Skip to content

Commit

Permalink
ExportisIgnoredByIgnoreFiles and isIgnoredByIgnoreFilesSync for s…
Browse files Browse the repository at this point in the history
…ome bottom level scene
  • Loading branch information
jiawei397 committed Sep 10, 2024
1 parent c000568 commit 2e0a0ca
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
40 changes: 40 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,3 +205,43 @@ export function isGitIgnored(options?: GitignoreOptions): Promise<GlobbyFilterFu
export function isGitIgnoredSync(options?: GitignoreOptions): GlobbyFilterFunction;

export function convertPathToPattern(source: string): FastGlob.Pattern;


Check failure on line 209 in index.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on ubuntu-latest

More than 1 blank line not allowed.

Check failure on line 209 in index.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on macos-latest

More than 1 blank line not allowed.

Check failure on line 209 in index.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 20 on windows-latest

More than 1 blank line not allowed.

Check failure on line 209 in index.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on ubuntu-latest

More than 1 blank line not allowed.

Check failure on line 209 in index.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on macos-latest

More than 1 blank line not allowed.

Check failure on line 209 in index.d.ts

View workflow job for this annotation

GitHub Actions / Node.js 18 on windows-latest

More than 1 blank line not allowed.
/**
* Check if a path is ignored by the ignore files.
* @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
* @param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
*
* @returns A filter function indicating whether a given path is ignored via the ignore files.
*
* @example
* ```
* import {isIgnoredByIgnoreFiles} from 'globby';
*
* const isIgnored = await isIgnoredByIgnoreFiles('**\/.gitignore');
*
* console.log(isIgnored('some/file'));
* ```
*/
export function isIgnoredByIgnoreFiles(
patterns: string | readonly string[],
options?: Options
): Promise<GlobbyFilterFunction>;

/**
* Check if a path is ignored by the ignore files.
* @see {@link isIgnoredByIgnoreFiles}
*
* @example
* ```js
* import {isIgnoredByIgnoreFilesSync} from 'globby';
*
* const isIgnored = isIgnoredByIgnoreFilesSync('**\/.gitignore');
*
* console.log(isIgnored('some/file'));
* ```
*/
export function isIgnoredByIgnoreFilesSync(
patterns: string | readonly string[],
options?: Options
): GlobbyFilterFunction;
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,8 @@ export const generateGlobTasksSync = normalizeArgumentsSync(generateTasksSync);
export {
isGitIgnored,
isGitIgnoredSync,
isIgnoredByIgnoreFiles,
isIgnoredByIgnoreFilesSync

Check failure on line 263 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20 on ubuntu-latest

Missing trailing comma.

Check failure on line 263 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20 on macos-latest

Missing trailing comma.

Check failure on line 263 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 20 on windows-latest

Missing trailing comma.

Check failure on line 263 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on ubuntu-latest

Missing trailing comma.

Check failure on line 263 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on macos-latest

Missing trailing comma.

Check failure on line 263 in index.js

View workflow job for this annotation

GitHub Actions / Node.js 18 on windows-latest

Missing trailing comma.
} from './ignore.js';

export const {convertPathToPattern} = fastGlob;
33 changes: 33 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,39 @@ Returns a `(path: URL | string) => boolean` indicating whether a given path is i

Takes `cwd?: URL | string` as options.


### isIgnoredByIgnoreFiles(patterns, options?)

Returns a `Promise<(path: URL | string) => boolean>` indicating whether a given path is ignored via an ignore file.

This is a more generic form of the `isGitIgnored` function, allowing you to find ignore files with a [compatible syntax](http://git-scm.com/docs/gitignore). For instance, this works with Babel's `.babelignore`, Prettier's `.prettierignore`, or ESLint's `.eslintignore` files.

Takes `cwd?: URL | string` as options.

```js
import {isIgnoredByIgnoreFiles} from 'globby';

const isIgnored = await isIgnoredByIgnoreFiles("**/.gitignore");

console.log(isIgnored('some/file'));
```

### isIgnoredByIgnoreFilesSync(patterns, options?)

Returns a `(path: URL | string) => boolean` indicating whether a given path is ignored via an ignore file.

This is a more generic form of the `isGitIgnoredSync` function, allowing you to find ignore files with a [compatible syntax](http://git-scm.com/docs/gitignore). For instance, this works with Babel's `.babelignore`, Prettier's `.prettierignore`, or ESLint's `.eslintignore` files.

Takes `cwd?: URL | string` as options.

```js
import {isIgnoredByIgnoreFilesSync} from 'globby';

const isIgnored = isIgnoredByIgnoreFilesSync("**/.gitignore");

console.log(isIgnored('some/file'));
```

## Globbing patterns

Just a quick overview.
Expand Down

0 comments on commit 2e0a0ca

Please sign in to comment.