@@ -4,21 +4,25 @@ const fs = require('fs-extra')
4
4
const glob = require ( 'it-glob' )
5
5
const Path = require ( 'path' )
6
6
const errCode = require ( 'err-code' )
7
+ const kindOf = require ( 'kind-of' )
7
8
8
9
/**
9
10
* Create an async iterator that yields paths that match requested file paths.
10
11
*
11
- * @param {String } ... paths File system path(s) to glob from
12
+ * @param {Iterable|AsyncIterable| String } paths File system path(s) to glob from
12
13
* @param {Object } [options] Optional options
13
14
* @param {Boolean } [options.recursive] Recursively glob all paths in directories
14
15
* @param {Boolean } [options.hidden] Include .dot files in matched paths
15
16
* @param {Array<String> } [options.ignore] Glob paths to ignore
16
17
* @param {Boolean } [options.followSymlinks] follow symlinks
17
18
* @yields {Object} File objects in the form `{ path: String, content: AsyncIterator<Buffer> }`
18
19
*/
19
- module . exports = async function * globSource ( ...args ) {
20
- const options = typeof args [ args . length - 1 ] === 'string' ? { } : args . pop ( )
21
- const paths = args
20
+ module . exports = async function * globSource ( paths , options ) {
21
+ options = options || { }
22
+
23
+ if ( kindOf ( paths ) === 'string' ) {
24
+ paths = [ paths ]
25
+ }
22
26
23
27
const globSourceOptions = {
24
28
recursive : options . recursive ,
@@ -30,7 +34,7 @@ module.exports = async function * globSource (...args) {
30
34
}
31
35
32
36
// Check the input paths comply with options.recursive and convert to glob sources
33
- for ( const path of paths ) {
37
+ for await ( const path of paths ) {
34
38
if ( typeof path !== 'string' ) {
35
39
throw errCode (
36
40
new Error ( `Path must be a string` ) ,
0 commit comments