@@ -251,14 +251,14 @@ export interface IGlobOptions {
251251}
252252
253253interface ParsedStringPattern {
254- ( path : string , basename : string ) : string | null | Promise < string | null > /* the matching pattern */ ;
254+ ( path : string , basename ? : string ) : string | null | Promise < string | null > /* the matching pattern */ ;
255255 basenames ?: string [ ] ;
256256 patterns ?: string [ ] ;
257257 allBasenames ?: string [ ] ;
258258 allPaths ?: string [ ] ;
259259}
260260interface ParsedExpressionPattern {
261- ( path : string , basename : string , name ?: string , hasSibling ?: ( name : string ) => boolean | Promise < boolean > ) : string | null | Promise < string | null > /* the matching pattern */ ;
261+ ( path : string , basename ? : string , name ?: string , hasSibling ?: ( name : string ) => boolean | Promise < boolean > ) : string | null | Promise < string | null > /* the matching pattern */ ;
262262 requiresSiblings ?: boolean ;
263263 allBasenames ?: string [ ] ;
264264 allPaths ?: string [ ] ;
@@ -374,7 +374,7 @@ function trivia3(pattern: string, options: IGlobOptions): ParsedStringPattern {
374374 if ( n === 1 ) {
375375 return < ParsedStringPattern > parsedPatterns [ 0 ] ;
376376 }
377- const parsedPattern : ParsedStringPattern = function ( path : string , basename : string ) {
377+ const parsedPattern : ParsedStringPattern = function ( path : string , basename ? : string ) {
378378 for ( let i = 0 , n = parsedPatterns . length ; i < n ; i ++ ) {
379379 if ( ( < ParsedStringPattern > parsedPatterns [ i ] ) ( path , basename ) ) {
380380 return pattern ;
@@ -409,7 +409,7 @@ function trivia4and5(path: string, pattern: string, matchPathEnds: boolean): Par
409409function toRegExp ( pattern : string ) : ParsedStringPattern {
410410 try {
411411 const regExp = new RegExp ( `^${ parseRegExp ( pattern ) } $` ) ;
412- return function ( path : string , basename : string ) {
412+ return function ( path : string ) {
413413 regExp . lastIndex = 0 ; // reset RegExp to its initial state to reuse it!
414414 return typeof path === 'string' && regExp . test ( path ) ? pattern : null ;
415415 } ;
@@ -457,7 +457,7 @@ export function parse(arg1: string | IExpression | IRelativePattern, options: IG
457457 if ( parsedPattern === NULL ) {
458458 return FALSE ;
459459 }
460- const resultPattern : ParsedPattern & { allBasenames ?: string [ ] ; allPaths ?: string [ ] ; } = function ( path : string , basename : string ) {
460+ const resultPattern : ParsedPattern & { allBasenames ?: string [ ] ; allPaths ?: string [ ] ; } = function ( path : string , basename ? : string ) {
461461 return ! ! parsedPattern ( path , basename ) ;
462462 } ;
463463 if ( parsedPattern . allBasenames ) {
@@ -540,7 +540,7 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse
540540 return < ParsedStringPattern > parsedPatterns [ 0 ] ;
541541 }
542542
543- const resultExpression : ParsedStringPattern = function ( path : string , basename : string ) {
543+ const resultExpression : ParsedStringPattern = function ( path : string , basename ? : string ) {
544544 for ( let i = 0 , n = parsedPatterns . length ; i < n ; i ++ ) {
545545 // Pattern matches path
546546 const result = ( < ParsedStringPattern > parsedPatterns [ i ] ) ( path , basename ) ;
@@ -565,7 +565,7 @@ function parsedExpression(expression: IExpression, options: IGlobOptions): Parse
565565 return resultExpression ;
566566 }
567567
568- const resultExpression : ParsedStringPattern = function ( path : string , basename : string , hasSibling ?: ( name : string ) => boolean | Promise < boolean > ) {
568+ const resultExpression : ParsedStringPattern = function ( path : string , basename ? : string , hasSibling ?: ( name : string ) => boolean | Promise < boolean > ) {
569569 let name : string | undefined = undefined ;
570570
571571 for ( let i = 0 , n = parsedPatterns . length ; i < n ; i ++ ) {
@@ -620,12 +620,12 @@ function parseExpressionPattern(pattern: string, value: boolean | SiblingClause,
620620 if ( value ) {
621621 const when = ( < SiblingClause > value ) . when ;
622622 if ( typeof when === 'string' ) {
623- const result : ParsedExpressionPattern = ( path : string , basename : string , name : string , hasSibling : ( name : string ) => boolean | Promise < boolean > ) => {
623+ const result : ParsedExpressionPattern = ( path : string , basename ? : string , name ? : string , hasSibling ? : ( name : string ) => boolean | Promise < boolean > ) => {
624624 if ( ! hasSibling || ! parsedPattern ( path , basename ) ) {
625625 return null ;
626626 }
627627
628- const clausePattern = when . replace ( '$(basename)' , name ) ;
628+ const clausePattern = when . replace ( '$(basename)' , name ! ) ;
629629 const matched = hasSibling ( clausePattern ) ;
630630 return isThenable ( matched ) ?
631631 matched . then ( m => m ? pattern : null ) :
0 commit comments