Skip to content

Commit eb9f02e

Browse files
committed
fix bug in example, options object is required
Also put a guard in place in the constructor itself to make this even more clear. Fix: #538
1 parent 44d2773 commit eb9f02e

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ const filesStream = globStream(['**/*.dat', 'logs/**/*.log'])
5555
// construct a Glob object if you wanna do it that way, which
5656
// allows for much faster walks if you have to look in the same
5757
// folder multiple times.
58-
const g = new Glob('**/foo')
58+
const g = new Glob('**/foo', {})
5959
// glob objects are async iterators, can also do globIterate() or
6060
// g.iterate(), same deal
6161
for await (const file of g) {
@@ -358,6 +358,8 @@ An object that can perform glob pattern traversals.
358358

359359
### `const g = new Glob(pattern: string | string[], options: GlobOptions)`
360360

361+
Options object is required.
362+
361363
See full options descriptions below.
362364

363365
Note that a previous `Glob` object can be passed as the

src/glob.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,9 @@ export class Glob<Opts extends GlobOptions> implements GlobOptions {
379379
* again.
380380
*/
381381
constructor(pattern: string | string[], opts: Opts) {
382+
/* c8 ignore start */
383+
if (!opts) throw new TypeError('glob options required')
384+
/* c8 ignore stop */
382385
this.withFileTypes = !!opts.withFileTypes as FileTypes<Opts>
383386
this.signal = opts.signal
384387
this.follow = !!opts.follow

0 commit comments

Comments
 (0)