diff options
author | Minteck <nekostarfan@gmail.com> | 2021-08-24 14:41:48 +0200 |
---|---|---|
committer | Minteck <nekostarfan@gmail.com> | 2021-08-24 14:41:48 +0200 |
commit | d25e11bee6ca5ca523884da132d18e1400e077b9 (patch) | |
tree | 8af39fde19f7ed640a60fb397c7edd647dff1c4c /node_modules/globby/index.d.ts | |
download | kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.gz kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.bz2 kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.zip |
Initial commit
Diffstat (limited to 'node_modules/globby/index.d.ts')
-rw-r--r-- | node_modules/globby/index.d.ts | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/node_modules/globby/index.d.ts b/node_modules/globby/index.d.ts new file mode 100644 index 0000000..2e563fc --- /dev/null +++ b/node_modules/globby/index.d.ts @@ -0,0 +1,186 @@ +import {Options as FastGlobOptions, Entry as FastGlobEntry} from 'fast-glob'; + +declare namespace globby { + type ExpandDirectoriesOption = + | boolean + | readonly string[] + | {files?: readonly string[]; extensions?: readonly string[]}; + + type Entry = FastGlobEntry; + + interface GlobbyOptions extends FastGlobOptions { + /** + If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `Object` with `files` and `extensions` like in the example below. + + Note that if you set this option to `false`, you won't get back matched directories unless you set `onlyFiles: false`. + + @default true + + @example + ``` + import globby = require('globby'); + + (async () => { + const paths = await globby('images', { + expandDirectories: { + files: ['cat', 'unicorn', '*.jpg'], + extensions: ['png'] + } + }); + + console.log(paths); + //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg'] + })(); + ``` + */ + readonly expandDirectories?: ExpandDirectoriesOption; + + /** + Respect ignore patterns in `.gitignore` files that apply to the globbed files. + + @default false + */ + readonly gitignore?: boolean; + } + + interface GlobTask { + readonly pattern: string; + readonly options: GlobbyOptions; + } + + interface GitignoreOptions { + readonly cwd?: string; + readonly ignore?: readonly string[]; + } + + type FilterFunction = (path: string) => boolean; +} + +interface Gitignore { + /** + @returns A filter function indicating whether a given path is ignored via a `.gitignore` file. + */ + sync: (options?: globby.GitignoreOptions) => globby.FilterFunction; + + /** + `.gitignore` files matched by the ignore config are not used for the resulting filter function. + + @returns A filter function indicating whether a given path is ignored via a `.gitignore` file. + + @example + ``` + import {gitignore} from 'globby'; + + (async () => { + const isIgnored = await gitignore(); + console.log(isIgnored('some/file')); + })(); + ``` + */ + (options?: globby.GitignoreOptions): Promise<globby.FilterFunction>; +} + +declare const globby: { + /** + Find files and directories using glob patterns. + + Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`. + + @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 The matching paths. + */ + sync: (( + patterns: string | readonly string[], + options: globby.GlobbyOptions & {objectMode: true} + ) => globby.Entry[]) & (( + patterns: string | readonly string[], + options?: globby.GlobbyOptions + ) => string[]); + + /** + Find files and directories using glob patterns. + + Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`. + + @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 The stream of matching paths. + + @example + ``` + import globby = require('globby'); + + (async () => { + for await (const path of globby.stream('*.tmp')) { + console.log(path); + } + })(); + ``` + */ + stream: ( + patterns: string | readonly string[], + options?: globby.GlobbyOptions + ) => NodeJS.ReadableStream; + + /** + Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration. + + @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 An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages. + */ + generateGlobTasks: ( + patterns: string | readonly string[], + options?: globby.GlobbyOptions + ) => globby.GlobTask[]; + + /** + Note that the options affect the results. + + This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options). + + @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). + @returns Whether there are any special glob characters in the `patterns`. + */ + hasMagic: ( + patterns: string | readonly string[], + options?: FastGlobOptions + ) => boolean; + + readonly gitignore: Gitignore; + + ( + patterns: string | readonly string[], + options: globby.GlobbyOptions & {objectMode: true} + ): Promise<globby.Entry[]>; + + /** + Find files and directories using glob patterns. + + Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`. + + @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 The matching paths. + + @example + ``` + import globby = require('globby'); + + (async () => { + const paths = await globby(['*', '!cake']); + + console.log(paths); + //=> ['unicorn', 'rainbow'] + })(); + ``` + */ + ( + patterns: string | readonly string[], + options?: globby.GlobbyOptions + ): Promise<string[]>; +}; + +export = globby; |