@@ -6615,7 +6615,7 @@ namespace ts {
6615
6615
includeFilePattern : getRegularExpressionForWildcard ( includes , absolutePath , "files" ) ,
6616
6616
includeDirectoryPattern : getRegularExpressionForWildcard ( includes , absolutePath , "directories" ) ,
6617
6617
excludePattern : getRegularExpressionForWildcard ( excludes , absolutePath , "exclude" ) ,
6618
- basePaths : getBasePaths ( absolutePath , includes , useCaseSensitiveFileNames )
6618
+ basePaths : getBasePaths ( path , includes , useCaseSensitiveFileNames )
6619
6619
} ;
6620
6620
}
6621
6621
@@ -6624,7 +6624,7 @@ namespace ts {
6624
6624
}
6625
6625
6626
6626
/** @param path directory of the tsconfig.json */
6627
- export function matchFiles ( path : string , extensions : readonly string [ ] | undefined , excludes : readonly string [ ] | undefined , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean , currentDirectory : string , depth : number | undefined , getFileSystemEntries : ( path : string ) => FileSystemEntries , realpath : ( path : string ) => string , directoryExists : ( path : string ) => boolean ) : string [ ] {
6627
+ export function matchFiles ( path : string , extensions : readonly string [ ] | undefined , excludes : readonly string [ ] | undefined , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean , currentDirectory : string , depth : number | undefined , getFileSystemEntries : ( path : string ) => FileSystemEntries , realpath : ( path : string ) => string ) : string [ ] {
6628
6628
path = normalizePath ( path ) ;
6629
6629
currentDirectory = normalizePath ( currentDirectory ) ;
6630
6630
@@ -6639,22 +6639,20 @@ namespace ts {
6639
6639
const results : string [ ] [ ] = includeFileRegexes ? includeFileRegexes . map ( ( ) => [ ] ) : [ [ ] ] ;
6640
6640
const visited = new Map < string , true > ( ) ;
6641
6641
const toCanonical = createGetCanonicalFileName ( useCaseSensitiveFileNames ) ;
6642
- for ( const absoluteBasePath of patterns . basePaths ) {
6643
- if ( directoryExists ( absoluteBasePath ) ) {
6644
- visitDirectory ( absoluteBasePath , depth ) ;
6645
- }
6642
+ for ( const basePath of patterns . basePaths ) {
6643
+ visitDirectory ( basePath , combinePaths ( currentDirectory , basePath ) , depth ) ;
6646
6644
}
6647
6645
6648
6646
return flatten ( results ) ;
6649
6647
6650
- function visitDirectory ( absolutePath : string , depth : number | undefined ) {
6648
+ function visitDirectory ( path : string , absolutePath : string , depth : number | undefined ) {
6651
6649
const canonicalPath = toCanonical ( realpath ( absolutePath ) ) ;
6652
6650
if ( visited . has ( canonicalPath ) ) return ;
6653
6651
visited . set ( canonicalPath , true ) ;
6654
- const { files, directories } = getFileSystemEntries ( absolutePath ) ;
6652
+ const { files, directories } = getFileSystemEntries ( path ) ;
6655
6653
6656
6654
for ( const current of sort < string > ( files , compareStringsCaseSensitive ) ) {
6657
- const name = combinePaths ( absolutePath , current ) ;
6655
+ const name = combinePaths ( path , current ) ;
6658
6656
const absoluteName = combinePaths ( absolutePath , current ) ;
6659
6657
if ( extensions && ! fileExtensionIsOneOf ( name , extensions ) ) continue ;
6660
6658
if ( excludeRegex && excludeRegex . test ( absoluteName ) ) continue ;
@@ -6677,32 +6675,32 @@ namespace ts {
6677
6675
}
6678
6676
6679
6677
for ( const current of sort < string > ( directories , compareStringsCaseSensitive ) ) {
6678
+ const name = combinePaths ( path , current ) ;
6680
6679
const absoluteName = combinePaths ( absolutePath , current ) ;
6681
6680
if ( ( ! includeDirectoryRegex || includeDirectoryRegex . test ( absoluteName ) ) &&
6682
6681
( ! excludeRegex || ! excludeRegex . test ( absoluteName ) ) ) {
6683
- visitDirectory ( absoluteName , depth ) ;
6682
+ visitDirectory ( name , absoluteName , depth ) ;
6684
6683
}
6685
6684
}
6686
6685
}
6687
6686
}
6688
6687
6689
6688
/**
6690
6689
* Computes the unique non-wildcard base paths amongst the provided include patterns.
6691
- * @returns Absolute directory paths
6692
6690
*/
6693
- function getBasePaths ( absoluteTsconfigPath : string , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean ) : string [ ] {
6691
+ function getBasePaths ( path : string , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean ) : string [ ] {
6694
6692
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
6695
- const basePaths : string [ ] = [ absoluteTsconfigPath ] ;
6693
+ const basePaths : string [ ] = [ path ] ;
6696
6694
6697
6695
if ( includes ) {
6698
6696
// Storage for literal base paths amongst the include patterns.
6699
6697
const includeBasePaths : string [ ] = [ ] ;
6700
6698
for ( const include of includes ) {
6701
6699
// We also need to check the relative paths by converting them to absolute and normalizing
6702
6700
// in case they escape the base path (e.g "..\somedirectory")
6703
- const absoluteIncludePath : string = isRootedDiskPath ( include ) ? include : normalizePath ( combinePaths ( absoluteTsconfigPath , include ) ) ;
6701
+ const absolute : string = isRootedDiskPath ( include ) ? include : normalizePath ( combinePaths ( path , include ) ) ;
6704
6702
// Append the literal and canonical candidate base paths.
6705
- includeBasePaths . push ( getIncludeBasePath ( absoluteIncludePath ) ) ;
6703
+ includeBasePaths . push ( getIncludeBasePath ( absolute ) ) ;
6706
6704
}
6707
6705
6708
6706
// Sort the offsets array using either the literal or canonical path representations.
@@ -6711,7 +6709,7 @@ namespace ts {
6711
6709
// Iterate over each include base path and include unique base paths that are not a
6712
6710
// subpath of an existing base path
6713
6711
for ( const includeBasePath of includeBasePaths ) {
6714
- if ( every ( basePaths , basePath => ! containsPath ( basePath , includeBasePath , absoluteTsconfigPath , ! useCaseSensitiveFileNames ) ) ) {
6712
+ if ( every ( basePaths , basePath => ! containsPath ( basePath , includeBasePath , path , ! useCaseSensitiveFileNames ) ) ) {
6715
6713
basePaths . push ( includeBasePath ) ;
6716
6714
}
6717
6715
}
0 commit comments