Skip to content

Commit

Permalink
Require Node.js 10
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jan 6, 2020
1 parent d4681a4 commit 4a471af
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 36 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,3 @@ language: node_js
node_js:
- '12'
- '10'
- '8'
1 change: 1 addition & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ declare namespace globby {
extensions: ['png']
}
});
console.log(paths);
//=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']
})();
Expand Down
19 changes: 10 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
{
"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",
"test": "xo && ava && tsd"
},
"files": [
"index.js",
"gitignore.js",
"index.d.ts",
"gitignore.js",
"stream-utils.js"
],
"keywords": [
Expand Down Expand Up @@ -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": {
Expand All @@ -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": [
Expand Down
18 changes: 5 additions & 13 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

```
Expand All @@ -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()`.
Expand All @@ -63,7 +59,7 @@ See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in

##### expandDirectories

Type: `boolean | string[] | object`<br>
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:
Expand All @@ -88,7 +84,7 @@ Note that if you set this option to `false`, you won't get back matched director

##### gitignore

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

Respect ignore patterns in `.gitignore` files that apply to the globbed files.
Expand Down Expand Up @@ -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');
Expand All @@ -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.
Expand All @@ -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
Expand Down
21 changes: 8 additions & 13 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import globby from '.';

const cwd = process.cwd();
const tmp = 'tmp';

const fixture = [
'a.tmp',
'b.tmp',
Expand Down Expand Up @@ -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']);
Expand Down

0 comments on commit 4a471af

Please sign in to comment.