@@ -24,18 +24,26 @@ const defaultPlatform: NodeJS.Platform =
2424 ? process . platform
2525 : 'linux'
2626
27- export interface GlobOptions extends MinimatchOptions {
28- ignore ?: string | string [ ] | Ignore
27+ export interface GlobOptions {
28+ absolute ?: boolean
29+ allowWindowsEscape ?: boolean
30+ cwd ?: string
31+ dot ?: boolean
2932 follow ?: boolean
33+ ignore ?: string | string [ ] | Ignore
3034 mark ?: boolean
35+ matchBase ?: boolean
36+ nobrace ?: boolean
37+ nocase ?: boolean
3138 nodir ?: boolean
32- cwd ?: string
39+ noext ?: boolean
40+ noglobstar ?: boolean
41+ platform ?: NodeJS . Platform
3342 realpath ?: boolean
34- absolute ?: boolean
35- withFileTypes ?: boolean
3643 scurry ?: PathScurry
37- platform ?: NodeJS . Platform
3844 signal ?: AbortSignal
45+ windowsPathsNoEscape ?: boolean
46+ withFileTypes ?: boolean
3947}
4048
4149export type GlobOptionsWithFileTypesTrue = GlobOptions & {
@@ -57,7 +65,7 @@ type Result<Opts> = Opts extends GlobOptionsWithFileTypesTrue
5765 : Opts extends GlobOptionsWithFileTypesUnset
5866 ? string
5967 : string | Path
60- type Results < Opts > = Result < Opts > [ ]
68+ export type Results < Opts > = Result < Opts > [ ]
6169
6270type FileTypes < Opts > = Opts extends GlobOptionsWithFileTypesTrue
6371 ? true
@@ -80,7 +88,6 @@ export class Glob<Opts extends GlobOptions> {
8088 globSet : GlobSet
8189 globParts : GlobParts
8290 realpath : boolean
83- nonull : boolean
8491 absolute : boolean
8592 matchBase : boolean
8693 windowsPathsNoEscape : boolean
@@ -95,6 +102,8 @@ export class Glob<Opts extends GlobOptions> {
95102 platform : NodeJS . Platform
96103 patterns : Pattern [ ]
97104 signal ?: AbortSignal
105+ nobrace : boolean
106+ noext : boolean
98107
99108 constructor ( pattern : string | string [ ] , opts : Opts ) {
100109 this . withFileTypes = ! ! opts . withFileTypes as FileTypes < Opts >
@@ -104,24 +113,16 @@ export class Glob<Opts extends GlobOptions> {
104113 this . nodir = ! ! opts . nodir
105114 this . mark = ! ! opts . mark
106115 this . cwd = opts . cwd || ''
116+ this . nobrace = ! ! opts . nobrace
117+ this . noext = ! ! opts . noext
107118 this . realpath = ! ! opts . realpath
108- this . nonull = ! ! opts . nonull
109119 this . absolute = ! ! opts . absolute
110120
111121 this . noglobstar = ! ! opts . noglobstar
112122 this . matchBase = ! ! opts . matchBase
113123
114- // if we're returning Path objects, we can't do nonull, because
115- // the pattern is a string, not a Path
116- if ( this . withFileTypes ) {
117- if ( this . nonull ) {
118- throw new TypeError (
119- 'cannot set nonull:true and withFileTypes:true'
120- )
121- }
122- if ( this . absolute ) {
123- throw new Error ( 'cannot set absolute:true and withFileTypes:true' )
124- }
124+ if ( this . withFileTypes && this . absolute ) {
125+ throw new Error ( 'cannot set absolute:true and withFileTypes:true' )
125126 }
126127
127128 if ( typeof pattern === 'string' ) {
@@ -149,6 +150,12 @@ export class Glob<Opts extends GlobOptions> {
149150 this . opts = { ...opts , platform : this . platform }
150151 if ( opts . scurry ) {
151152 this . scurry = opts . scurry
153+ if (
154+ opts . nocase !== undefined &&
155+ opts . nocase !== opts . scurry . nocase
156+ ) {
157+ throw new Error ( 'nocase option contradicts provided scurry option' )
158+ }
152159 } else {
153160 const Scurry =
154161 opts . platform === 'win32'
@@ -170,13 +177,18 @@ export class Glob<Opts extends GlobOptions> {
170177
171178 const mmo : MinimatchOptions = {
172179 // default nocase based on platform
173- nocase : this . nocase ,
174180 ...opts ,
175- nonegate : true ,
176- nocomment : true ,
181+ dot : this . dot ,
182+ matchBase : this . matchBase ,
183+ nobrace : this . nobrace ,
184+ nocase : this . nocase ,
177185 nocaseMagicOnly : true ,
186+ nocomment : true ,
187+ noext : this . noext ,
188+ nonegate : true ,
178189 optimizationLevel : 2 ,
179190 platform : this . platform ,
191+ windowsPathsNoEscape : this . windowsPathsNoEscape ,
180192 }
181193
182194 const mms = this . pattern . map ( p => new Minimatch ( p , mmo ) )
@@ -224,35 +236,35 @@ export class Glob<Opts extends GlobOptions> {
224236 return [ ...matches ]
225237 }
226238
227- stream ( ) : Minipass < Result < Opts > >
228- stream ( ) : Minipass < string | Path > {
239+ stream ( ) : Minipass < Result < Opts > , Result < Opts > >
240+ stream ( ) : Minipass < string | Path , string | Path > {
229241 return new GlobStream ( this . patterns , this . scurry . cwd , {
230242 ...this . opts ,
231243 platform : this . platform ,
232244 nocase : this . nocase ,
233245 } ) . stream ( )
234246 }
235247
236- streamSync ( ) : Minipass < Result < Opts > >
237- streamSync ( ) : Minipass < string | Path > {
248+ streamSync ( ) : Minipass < Result < Opts > , Result < Opts > >
249+ streamSync ( ) : Minipass < string | Path , string | Path > {
238250 return new GlobStream ( this . patterns , this . scurry . cwd , {
239251 ...this . opts ,
240252 platform : this . platform ,
241253 nocase : this . nocase ,
242254 } ) . streamSync ( )
243255 }
244256
245- iteratorSync ( ) : Generator < Result < Opts > , void , void > {
257+ iterateSync ( ) : Generator < Result < Opts > , void , void > {
246258 return this . streamSync ( ) [ Symbol . iterator ] ( )
247259 }
248260 [ Symbol . iterator ] ( ) {
249- return this . iteratorSync ( )
261+ return this . iterateSync ( )
250262 }
251263
252- iterator ( ) : AsyncGenerator < Result < Opts > , void , void > {
264+ iterate ( ) : AsyncGenerator < Result < Opts > , void , void > {
253265 return this . stream ( ) [ Symbol . asyncIterator ] ( )
254266 }
255267 [ Symbol . asyncIterator ] ( ) {
256- return this . iterator ( )
268+ return this . iterate ( )
257269 }
258270}
0 commit comments