Match files using the patterns the shell uses, like stars and stuff.
Important
Glob has native Promise support as of v9.0.0
, please use it directly.
I will not issue a deprecation notice on this package, because I can't deal with the volume of angry tickets that will follow.
npm install glob-promise glob
glob
is set as a peerDependency
in package.json
npm
>= 7 will automatically installpeerDependencies
npm
<= 6 will not automatically installpeerDependencies
.
You will need to manually add glob
as a dependency to your project for glob-promise
to work.
Alias for glob.promise
pattern: String
(glob pattern)
options: Object
or String
Return: Object
(Promise)
When it finishes, it will be fulfilled with an Array
of filenames as its first argument.
When it fails to read the files, it will be rejected with an error as its first argument.
glob('**/*')
.then(function(contents) {
contents; //=> ['lorem', 'ipsum', 'dolor']
});
glob('{foo,bar.baz}.txt', { nobrace: true })
.then(function(contents) {
contents; //=> []
});
see
glob
see
glob.sync()
see
glob.hasMagic()
see
Glob
The option object will be directly passed to glob.
Author: Ahmad Nassri • Twitter: @AhmadNassri