diff --git a/.travis.yml b/.travis.yml index 29ef4bf..4735b65 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,4 +6,3 @@ language: node_js node_js: - '12' - '10' - - '8' diff --git a/index.d.ts b/index.d.ts index ad9176c..c40e4fe 100644 --- a/index.d.ts +++ b/index.d.ts @@ -25,6 +25,7 @@ declare namespace globby { extensions: ['png'] } }); + console.log(paths); //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg'] })(); diff --git a/package.json b/package.json index 38d9f17..b44938d 100644 --- a/package.json +++ b/package.json @@ -1,16 +1,17 @@ { "name": "globby", "version": "10.0.2", - "description": "Extends `glob` with support for multiple patterns and exposes a Promise API", + "description": "User-friendly glob matching", "license": "MIT", "repository": "sindresorhus/globby", + "funding": "https://github.com/sponsors/sindresorhus", "author": { "email": "sindresorhus@gmail.com", "name": "Sindre Sorhus", "url": "sindresorhus.com" }, "engines": { - "node": ">=8" + "node": ">=10" }, "scripts": { "bench": "npm update glob-stream fast-glob && matcha bench.js", @@ -18,8 +19,8 @@ }, "files": [ "index.js", - "gitignore.js", "index.d.ts", + "gitignore.js", "stream-utils.js" ], "keywords": [ @@ -58,9 +59,9 @@ "dependencies": { "array-union": "^2.1.0", "dir-glob": "^3.0.1", - "fast-glob": "^3.1.0", - "ignore": "^5.1.1", - "merge2": "^1.2.3", + "fast-glob": "^3.1.1", + "ignore": "^5.1.4", + "merge2": "^1.3.0", "slash": "^3.0.0" }, "devDependencies": { @@ -69,9 +70,9 @@ "glob-stream": "^6.1.0", "globby": "sindresorhus/globby#master", "matcha": "^0.7.0", - "rimraf": "^2.6.3", - "tsd": "^0.7.3", - "xo": "^0.24.0" + "rimraf": "^3.0.0", + "tsd": "^0.11.0", + "xo": "^0.25.3" }, "xo": { "ignores": [ diff --git a/readme.md b/readme.md index 3a92f6f..709e5aa 100644 --- a/readme.md +++ b/readme.md @@ -2,25 +2,22 @@ > User-friendly glob matching -Based on [`fast-glob`](https://github.com/mrmlnc/fast-glob), but adds a bunch of useful features and a nicer API. - +Based on [`fast-glob`](https://github.com/mrmlnc/fast-glob) but adds a bunch of useful features. ## Features - Promise API - Multiple patterns - Negated patterns: `['foo*', '!foobar']` -- Expands directories: `dir` → `dir/**/*` +- Expands directories: `foo` → `foo/**/*` - Supports `.gitignore` - ## Install ``` $ npm install globby ``` - ## Usage ``` @@ -40,7 +37,6 @@ const globby = require('globby'); })(); ``` - ## API 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()`. @@ -63,7 +59,7 @@ See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in ##### expandDirectories -Type: `boolean | string[] | object`
+Type: `boolean | string[] | object`\ Default: `true` 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 below: @@ -88,7 +84,7 @@ Note that if you set this option to `false`, you won't get back matched director ##### gitignore -Type: `boolean`
+Type: `boolean`\ Default: `false` Respect ignore patterns in `.gitignore` files that apply to the globbed files. @@ -131,8 +127,7 @@ This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isd Returns a `Promise<(path: string) => boolean>` indicating whether a given path is ignored via a `.gitignore` file. -Takes `cwd?: string` and `ignore?: string[]` as options. `.gitignore` files matched by the ignore config are not -used for the resulting filter function. +Takes `cwd?: string` and `ignore?: string[]` as options. `.gitignore` files matched by the ignore config are not used for the resulting filter function. ```js const {gitignore} = require('globby'); @@ -149,7 +144,6 @@ Returns a `(path: string) => boolean` indicating whether a given path is ignored Takes the same options as `globby.gitignore`. - ## Globbing patterns Just a quick overview. @@ -162,14 +156,12 @@ Just a quick overview. [Various patterns and expected matches.](https://github.com/sindresorhus/multimatch/blob/master/test/test.js) - ## globby for enterprise Available as part of the Tidelift Subscription. The maintainers of globby and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-globby?utm_source=npm-globby&utm_medium=referral&utm_campaign=enterprise&utm_term=repo) - ## Related - [multimatch](https://github.com/sindresorhus/multimatch) - Match against a list instead of the filesystem diff --git a/test.js b/test.js index 68749b1..10c800d 100644 --- a/test.js +++ b/test.js @@ -7,6 +7,7 @@ import globby from '.'; const cwd = process.cwd(); const tmp = 'tmp'; + const fixture = [ 'a.tmp', 'b.tmp', @@ -77,20 +78,14 @@ test('glob - stream', async t => { t.deepEqual((await getStream.array(globby.stream('*.tmp'))).sort(), ['a.tmp', 'b.tmp', 'c.tmp', 'd.tmp', 'e.tmp']); }); -// Readable streams are iterable since Node.js 10, but this test runs on 6 and 8 too. -// So we define the test only if async iteration is supported. -if (Symbol.asyncIterator) { - // For the reason behind `eslint-disable` below see https://github.com/avajs/eslint-plugin-ava/issues/216 - // eslint-disable-next-line ava/no-async-fn-without-await - test('glob - stream async iterator support', async t => { - const results = []; - for await (const path of globby.stream('*.tmp')) { - results.push(path); - } +test('glob - stream async iterator support', async t => { + const results = []; + for await (const path of globby.stream('*.tmp')) { + results.push(path); + } - t.deepEqual(results, ['a.tmp', 'b.tmp', 'c.tmp', 'd.tmp', 'e.tmp']); - }); -} + t.deepEqual(results, ['a.tmp', 'b.tmp', 'c.tmp', 'd.tmp', 'e.tmp']); +}); test('glob - stream - multiple file paths', async t => { t.deepEqual(await getStream.array(globby.stream(['a.tmp', 'b.tmp'])), ['a.tmp', 'b.tmp']);