{"id":15664768,"url":"https://github.com/kaelzhang/node-glob-gitignore","last_synced_at":"2025-04-12T10:11:45.291Z","repository":{"id":44584454,"uuid":"91586737","full_name":"kaelzhang/node-glob-gitignore","owner":"kaelzhang","description":"Extends `glob` with support for filtering files according to gitignore rules and exposes an optional Promise API","archived":false,"fork":false,"pushed_at":"2024-09-24T11:09:16.000Z","size":28,"stargazers_count":19,"open_issues_count":2,"forks_count":5,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-11T06:25:28.045Z","etag":null,"topics":["gitignore-rules","glob","nodejs","promise"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaelzhang.png","metadata":{"files":{"readme":"README.md","changelog":"HISTORY.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-05-17T14:39:35.000Z","updated_at":"2025-03-08T14:16:22.000Z","dependencies_parsed_at":"2024-11-10T03:27:15.332Z","dependency_job_id":"be0e7458-49d2-4bb4-9707-65d04aff879f","html_url":"https://github.com/kaelzhang/node-glob-gitignore","commit_stats":{"total_commits":29,"total_committers":2,"mean_commits":14.5,"dds":0.03448275862068961,"last_synced_commit":"660447149f934633c4d9c3ae2d682828f9b8641c"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fnode-glob-gitignore","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fnode-glob-gitignore/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fnode-glob-gitignore/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaelzhang%2Fnode-glob-gitignore/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaelzhang","download_url":"https://codeload.github.com/kaelzhang/node-glob-gitignore/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248550633,"owners_count":21122933,"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":["gitignore-rules","glob","nodejs","promise"],"created_at":"2024-10-03T13:44:06.564Z","updated_at":"2025-04-12T10:11:45.264Z","avatar_url":"https://github.com/kaelzhang.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Build Status](https://github.com/kaelzhang/node-glob-gitignore/actions/workflows/nodejs.yml/badge.svg)](https://github.com/kaelzhang/node-glob-gitignore/actions/workflows/nodejs.yml)\n\u003c!-- optional appveyor tst\n[![Windows Build Status](https://ci.appveyor.com/api/projects/status/github/kaelzhang/node-glob-gitignore?branch=master\u0026svg=true)](https://ci.appveyor.com/project/kaelzhang/node-glob-gitignore)\n--\u003e\n\u003c!-- optional npm version\n[![NPM version](https://badge.fury.io/js/glob-gitignore.svg)](http://badge.fury.io/js/glob-gitignore)\n--\u003e\n\u003c!-- optional npm downloads\n[![npm module downloads per month](http://img.shields.io/npm/dm/glob-gitignore.svg)](https://www.npmjs.org/package/glob-gitignore)\n--\u003e\n\u003c!-- optional dependency status\n[![Dependency Status](https://david-dm.org/kaelzhang/node-glob-gitignore.svg)](https://david-dm.org/kaelzhang/node-glob-gitignore)\n--\u003e\n\n# glob-gitignore\n\nExtends [`glob`](https://www.npmjs.com/package/glob) with support for filtering files according to gitignore rules and exposes an optional Promise API, based on [`node-ignore`](https://www.npmjs.com/package/ignore).\n\nThis module is built to solve performance issues, see [Why](#why).\n\n## Install\n\n```sh\n$ npm i glob-gitignore --save\n```\n\n## Usage\n\n```js\nimport {\n  glob,\n  sync,\n  hasMagic\n} from 'glob-gitignore'\n\n// The usage of glob-gitignore is much the same as `node-glob`,\n// and it supports an array of patterns to be matched\nglob(['**'], {\n  cwd: '/path/to',\n\n  // Except that options.ignore accepts an array of gitignore rules,\n  // or a gitignore rule,\n  // or an `ignore` instance.\n  ignore: '*.bak'\n})\n// And glob-gitignore returns a promise\n.then(files =\u003e {\n  console.log(files)\n})\n\n// A string of pattern is also supported.\nglob('**', options)\n\n// To glob things synchronously, use `sync`\nconst files = sync('**', {ignore: '*.bak'})\n\nhasMagic('a/{b/c,x/y}')  // true\n```\n\n## Why\n\n1. The `options.ignore` of `node-glob` does not support gitignore rules.\n\n2. It is better **NOT** to glob things then filter them by gitignore rules. Because by doing this, there will be so much unnecessary harddisk traversing, and cause performance issues, especially if there are tremendous files and directories inside the working directory. For the situation, you'd better to use this module.\n\n`glob-gitignore` does the filtering at the very process of each decending down.\n\n## glob(patterns, options)\n\nReturns a `Promise`\n\n- **patterns** `String|Array.\u003cString\u003e` The pattern or array of patterns to be matched.\n\nAnd negative patterns (each of which starts with an `!`) are supported, although negative patterns are **NOT** recommended. You'd better to use `options.ignore`.\n\n```js\nglob(['*.js', 'a/**', '!a/**/*.png']).then(console.log)\n```\n\n- **options** `Object` the [glob options](https://www.npmjs.com/package/glob#options) except for `options.ignore`\n\n### `options.ignore`\n\nCould be a `String`, an array of `String`s, or an instance of [node-`ignore`](https://www.npmjs.com/package/ignore)\n\nNot setting this is kind of silly, since that's the whole purpose of this lib, but it is optional though.\n\n```js\nglob('**', {ignore: '*.js'})\nglob('**', {ignore: ['*.css', '*.styl']})\n\nimport ignore from 'ignore'\nglob('**', {\n  ignore: ignore().add('*.js')\n})\n```\n\n## sync(patterns, options)\n\nThe synchronous globber, which returns an `Array.\u003cpath\u003e`.\n\n## hasMagic(patterns, [options])\n\nThis method extends `glob.hasMagic(pattern)` and supports an array of patterns.\n\nReturns\n\n- `true` if there are any special characters in the pattern, or there is any of a pattern in the array has special characters.\n- `false` otherwise.\n\n```js\nhasMagic('a/{b/c,x/y}')               // true\nhasMagic(['a/{b/c,x/y}', 'a'])        // true\nhasMagic(['a'])                       // false\n```\n\nNote that the options affect the results. If `noext:true` is set in the options object, then `+(a|b)` will not be considered a magic pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}` then that is considered magical, unless `nobrace:true` is set in the options.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaelzhang%2Fnode-glob-gitignore","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaelzhang%2Fnode-glob-gitignore","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaelzhang%2Fnode-glob-gitignore/lists"}