Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Export isIgnoredByIgnoreFiles and isIgnoredByIgnoreFilesSync for some bottom level scene #269

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
ExportisIgnoredByIgnoreFiles and isIgnoredByIgnoreFilesSync for s…
…ome bottom level scene
  • Loading branch information
jiawei397 committed Sep 10, 2024
commit 2e0a0caba998598245b09fc20b8cea20645f88d8
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 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 {
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
Loading