{"id":13410707,"url":"https://github.com/sindresorhus/globby","last_synced_at":"2025-05-12T05:32:38.615Z","repository":{"id":18031222,"uuid":"21069494","full_name":"sindresorhus/globby","owner":"sindresorhus","description":"User-friendly glob matching","archived":false,"fork":false,"pushed_at":"2025-02-08T10:59:40.000Z","size":204,"stargazers_count":2578,"open_issues_count":37,"forks_count":131,"subscribers_count":22,"default_branch":"main","last_synced_at":"2025-05-07T18:50:18.490Z","etag":null,"topics":["directories","files","glob","globbing","javascript","matching","nodejs","patterns"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sindresorhus.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"license","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/security.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"sindresorhus","open_collective":"sindresorhus","buy_me_a_coffee":"sindresorhus","custom":"https://sindresorhus.com/donate"}},"created_at":"2014-06-21T13:48:39.000Z","updated_at":"2025-05-07T11:58:53.000Z","dependencies_parsed_at":"2023-11-17T18:02:36.693Z","dependency_job_id":"948a2e86-ae84-4d10-a6f3-b1b270228f2c","html_url":"https://github.com/sindresorhus/globby","commit_stats":{"total_commits":217,"total_committers":50,"mean_commits":4.34,"dds":"0.49769585253456217","last_synced_commit":"c000568bd20c97d94397c71ec22df4e1c5f41d47"},"previous_names":[],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fglobby","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fglobby/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fglobby/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sindresorhus%2Fglobby/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sindresorhus","download_url":"https://codeload.github.com/sindresorhus/globby/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253009901,"owners_count":21839715,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["directories","files","glob","globbing","javascript","matching","nodejs","patterns"],"created_at":"2024-07-30T20:01:08.551Z","updated_at":"2025-05-08T18:02:45.325Z","avatar_url":"https://github.com/sindresorhus.png","language":"JavaScript","readme":"# globby\n\n\u003e User-friendly glob matching\n\nBased on [`fast-glob`](https://github.com/mrmlnc/fast-glob) but adds a bunch of useful features.\n\n## Features\n\n- Promise API\n- Multiple patterns\n- Negated patterns: `['foo*', '!foobar']`\n- Expands directories: `foo` → `foo/**/*`\n- Supports `.gitignore` and similar ignore config files\n- Supports `URL` as `cwd`\n\n## Install\n\n```sh\nnpm install globby\n```\n\n## Usage\n\n```\n├── unicorn\n├── cake\n└── rainbow\n```\n\n```js\nimport {globby} from 'globby';\n\nconst paths = await globby(['*', '!cake']);\n\nconsole.log(paths);\n//=\u003e ['unicorn', 'rainbow']\n```\n\n## API\n\nNote 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()`.\n\n### globby(patterns, options?)\n\nReturns a `Promise\u003cstring[]\u003e` of matching paths.\n\n#### patterns\n\nType: `string | string[]`\n\nSee supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage).\n\n#### options\n\nType: `object`\n\nSee the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones below.\n\n##### expandDirectories\n\nType: `boolean | string[] | object`\\\nDefault: `true`\n\nIf 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 below:\n\n```js\nimport {globby} from 'globby';\n\nconst paths = await globby('images', {\n\texpandDirectories: {\n\t\tfiles: ['cat', 'unicorn', '*.jpg'],\n\t\textensions: ['png']\n\t}\n});\n\nconsole.log(paths);\n//=\u003e ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']\n```\n\nNote that if you set this option to `false`, you won't get back matched directories unless you set `onlyFiles: false`.\n\n##### gitignore\n\nType: `boolean`\\\nDefault: `false`\n\nRespect ignore patterns in `.gitignore` files that apply to the globbed files.\n\n##### ignoreFiles\n\nType: `string | string[]`\\\nDefault: `undefined`\n\nGlob patterns to look for ignore files, which are then used to ignore globbed files.\n\nThis is a more generic form of the `gitignore` option, 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.\n\n### globbySync(patterns, options?)\n\nReturns `string[]` of matching paths.\n\n### globbyStream(patterns, options?)\n\nReturns a [`stream.Readable`](https://nodejs.org/api/stream.html#stream_readable_streams) of matching paths.\n\nFor example, loop over glob matches in a [`for await...of` loop](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of) like this:\n\n```js\nimport {globbyStream} from 'globby';\n\nfor await (const path of globbyStream('*.tmp')) {\n\tconsole.log(path);\n}\n```\n\n### convertPathToPattern(path)\n\nConvert a path to a pattern. [Learn more.](https://github.com/mrmlnc/fast-glob#convertpathtopatternpath)\n\n### generateGlobTasks(patterns, options?)\n\nReturns an `Promise\u003cobject[]\u003e` in the format `{patterns: 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.\n\nNote 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.\n\n### generateGlobTasksSync(patterns, options?)\n\nReturns an `object[]` in the format `{patterns: 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.\n\nTakes the same arguments as `generateGlobTasks`.\n\n### isDynamicPattern(patterns, options?)\n\nReturns a `boolean` of whether there are any special glob characters in the `patterns`.\n\nNote that the options affect the results.\n\nThis function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options).\n\n### isGitIgnored(options?)\n\nReturns a `Promise\u003c(path: URL | string) =\u003e boolean\u003e` indicating whether a given path is ignored via a `.gitignore` file.\n\nTakes `cwd?: URL | string` as options.\n\n```js\nimport {isGitIgnored} from 'globby';\n\nconst isIgnored = await isGitIgnored();\n\nconsole.log(isIgnored('some/file'));\n```\n\n### isGitIgnoredSync(options?)\n\nReturns a `(path: URL | string) =\u003e boolean` indicating whether a given path is ignored via a `.gitignore` file.\n\nTakes `cwd?: URL | string` as options.\n\n\n### isIgnoredByIgnoreFiles(patterns, options?)\n\nReturns a `Promise\u003c(path: URL | string) =\u003e boolean\u003e` indicating whether a given path is ignored via the ignore files.\n\nThis 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.\n\nTakes `cwd?: URL | string` as options.\n\n```js\nimport {isIgnoredByIgnoreFiles} from 'globby';\n\nconst isIgnored = await isIgnoredByIgnoreFiles(\"**/.gitignore\");\n\nconsole.log(isIgnored('some/file'));\n```\n\n### isIgnoredByIgnoreFilesSync(patterns, options?)\n\nReturns a `(path: URL | string) =\u003e boolean` indicating whether a given path is ignored via the ignore files.\n\nThis 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.\n\nTakes `cwd?: URL | string` as options.\n\n```js\nimport {isIgnoredByIgnoreFilesSync} from 'globby';\n\nconst isIgnored = isIgnoredByIgnoreFilesSync(\"**/.gitignore\");\n\nconsole.log(isIgnored('some/file'));\n```\n\n## Globbing patterns\n\nJust a quick overview.\n\n- `*` matches any number of characters, but not `/`\n- `?` matches a single character, but not `/`\n- `**` matches any number of characters, including `/`, as long as it's the only thing in a path part\n- `{}` allows for a comma-separated list of \"or\" expressions\n- `!` at the beginning of a pattern will negate the match\n\n[Various patterns and expected matches.](https://github.com/sindresorhus/multimatch/blob/main/test/test.js)\n\n## Related\n\n- [multimatch](https://github.com/sindresorhus/multimatch) - Match against a list instead of the filesystem\n- [matcher](https://github.com/sindresorhus/matcher) - Simple wildcard matching\n- [del](https://github.com/sindresorhus/del) - Delete files and directories\n- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed\n","funding_links":["https://github.com/sponsors/sindresorhus","https://opencollective.com/sindresorhus","https://buymeacoffee.com/sindresorhus","https://sindresorhus.com/donate"],"categories":["JavaScript","Packages","Repository","GIT 仓库","包","目录","Filesystem","Utilities","nodejs","Uncategorized","Node"],"sub_categories":["Filesystem","文件系统","React Components","Uncategorized","文件处理"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fglobby","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsindresorhus%2Fglobby","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsindresorhus%2Fglobby/lists"}