UNPKG

2.79 kBMarkdownView Raw
1# Promise version of glob
2
3Match files using the patterns the shell uses, like stars and stuff.
4
5[![license][license-img]][license-url]
6[![release][release-img]][release-url]
7[![semantic][semantic-img]][semantic-url]
8
9> ***Note**: This is just a [`Promise`][] wrapped version of [`glob`][]*
10
11## Install
12
13``` bash
14$ npm install glob-promise glob
15```
16
17###### NOTE:
18
19[`glob`][] is set as a `peerDependency` in [`package.json`][]
20
21- `npm` \<= `2` will automatically install `peerDependencies` if they are not explicitly depended upon higher in the dependency tree.
22- `npm` \>= 3 will no longer automatically install `peerDependencies`.
23
24You will need to manually add `glob` as a dependency to your project for `glob-promise` to work.
25
26## API
27
28### `glob(pattern [, options])`
29
30Alias for `glob.promise`
31
32### `glob.promise(pattern [, options])`
33
34*pattern*: `String` (glob pattern)
35*options*: `Object` or `String`
36Return: `Object` ([Promise][`Promise`])
37
38When it finishes, it will be [*fulfilled*][] with an `Array` of filenames as its first argument.
39
40When it fails to read the files, it will be [*rejected*][] with an error as its first argument.
41
42``` js
43glob('**/*')
44 .then(function(contents) {
45 contents; //=> ['lorem', 'ipsum', 'dolor']
46 });
47
48glob('{foo,bar.baz}.txt', { nobrace: true })
49 .then(function(contents) {
50 contents; //=> []
51 });
52```
53
54### `glob.glob(pattern [, options], cb)`
55
56> see [`glob`][1]
57
58### `glob.sync(pattern [, options])`
59
60> see [`glob.sync()`][]
61
62### `glob.hasMagic(pattern, [options])`
63
64> see [`glob.hasMagic()`][]
65
66### `Class: glob.Glob`
67
68> see [`Glob`][2]
69
70#### options
71
72The option object will be directly passed to [glob][].
73
74 [`Promise`]: http://promisesaplus.com/
75 [`glob`]: https://github.com/isaacs/node-glob
76 [`package.json`]: package.json
77 [*fulfilled*]: http://promisesaplus.com/#point-26
78 [*rejected*]: http://promisesaplus.com/#point-30
79 [1]: https://github.com/isaacs/node-glob#globpattern-options-cb
80 [`glob.sync()`]: https://github.com/isaacs/node-glob#globsyncpattern-options
81 [`glob.hasMagic()`]: https://github.com/isaacs/node-glob#globhasmagicpattern-options
82 [2]: https://github.com/isaacs/node-glob#class-globglob
83 [glob]: https://github.com/isaacs/node-glob#options
84
85----
86> Author: [Ahmad Nassri](https://www.ahmadnassri.com/) &bull;
87> Twitter: [@AhmadNassri](https://twitter.com/AhmadNassri)
88
89[license-url]: LICENSE
90[license-img]: https://badgen.net/github/license/ahmadnassri/node-glob-promise
91
92[release-url]: https://github.com/ahmadnassri/node-glob-promise/releases
93[release-img]: https://badgen.net/github/release/ahmadnassri/node-glob-promise
94
95[semantic-url]: https://github.com/ahmadnassri/node-glob-promise/actions?query=workflow%3Arelease
96[semantic-img]: https://badgen.net/badge/📦/semantically%20released/blue