Skip to content

Commit

Permalink
fix bug in example, options object is required
Browse files Browse the repository at this point in the history
Also put a guard in place in the constructor itself to make this even
more clear.

Fix: #538
  • Loading branch information
isaacs committed Jul 8, 2023
1 parent 44d2773 commit eb9f02e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const filesStream = globStream(['**/*.dat', 'logs/**/*.log'])
// construct a Glob object if you wanna do it that way, which
// allows for much faster walks if you have to look in the same
// folder multiple times.
const g = new Glob('**/foo')
const g = new Glob('**/foo', {})
// glob objects are async iterators, can also do globIterate() or
// g.iterate(), same deal
for await (const file of g) {
Expand Down Expand Up @@ -358,6 +358,8 @@ An object that can perform glob pattern traversals.

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

Options object is required.

See full options descriptions below.

Note that a previous `Glob` object can be passed as the
Expand Down
3 changes: 3 additions & 0 deletions src/glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,9 @@ export class Glob<Opts extends GlobOptions> implements GlobOptions {
* again.
*/
constructor(pattern: string | string[], opts: Opts) {
/* c8 ignore start */
if (!opts) throw new TypeError('glob options required')
/* c8 ignore stop */
this.withFileTypes = !!opts.withFileTypes as FileTypes<Opts>
this.signal = opts.signal
this.follow = !!opts.follow
Expand Down

0 comments on commit eb9f02e

Please sign in to comment.