@@ -6629,7 +6629,7 @@ namespace ts {
6629
6629
includeFilePattern : getRegularExpressionForWildcard ( includes , absolutePath , "files" ) ,
6630
6630
includeDirectoryPattern : getRegularExpressionForWildcard ( includes , absolutePath , "directories" ) ,
6631
6631
excludePattern : getRegularExpressionForWildcard ( excludes , absolutePath , "exclude" ) ,
6632
- basePaths : getBasePaths ( absolutePath , includes , useCaseSensitiveFileNames )
6632
+ basePaths : getBasePaths ( path , includes , useCaseSensitiveFileNames )
6633
6633
} ;
6634
6634
}
6635
6635
@@ -6638,7 +6638,7 @@ namespace ts {
6638
6638
}
6639
6639
6640
6640
/** @param path directory of the tsconfig.json */
6641
- 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 [ ] {
6641
+ 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 [ ] {
6642
6642
path = normalizePath ( path ) ;
6643
6643
currentDirectory = normalizePath ( currentDirectory ) ;
6644
6644
@@ -6653,22 +6653,20 @@ namespace ts {
6653
6653
const results : string [ ] [ ] = includeFileRegexes ? includeFileRegexes . map ( ( ) => [ ] ) : [ [ ] ] ;
6654
6654
const visited = new Map < string , true > ( ) ;
6655
6655
const toCanonical = createGetCanonicalFileName ( useCaseSensitiveFileNames ) ;
6656
- for ( const absoluteBasePath of patterns . basePaths ) {
6657
- if ( directoryExists ( absoluteBasePath ) ) {
6658
- visitDirectory ( absoluteBasePath , depth ) ;
6659
- }
6656
+ for ( const basePath of patterns . basePaths ) {
6657
+ visitDirectory ( basePath , combinePaths ( currentDirectory , basePath ) , depth ) ;
6660
6658
}
6661
6659
6662
6660
return flatten ( results ) ;
6663
6661
6664
- function visitDirectory ( absolutePath : string , depth : number | undefined ) {
6662
+ function visitDirectory ( path : string , absolutePath : string , depth : number | undefined ) {
6665
6663
const canonicalPath = toCanonical ( realpath ( absolutePath ) ) ;
6666
6664
if ( visited . has ( canonicalPath ) ) return ;
6667
6665
visited . set ( canonicalPath , true ) ;
6668
- const { files, directories } = getFileSystemEntries ( absolutePath ) ;
6666
+ const { files, directories } = getFileSystemEntries ( path ) ;
6669
6667
6670
6668
for ( const current of sort < string > ( files , compareStringsCaseSensitive ) ) {
6671
- const name = combinePaths ( absolutePath , current ) ;
6669
+ const name = combinePaths ( path , current ) ;
6672
6670
const absoluteName = combinePaths ( absolutePath , current ) ;
6673
6671
if ( extensions && ! fileExtensionIsOneOf ( name , extensions ) ) continue ;
6674
6672
if ( excludeRegex && excludeRegex . test ( absoluteName ) ) continue ;
@@ -6691,32 +6689,32 @@ namespace ts {
6691
6689
}
6692
6690
6693
6691
for ( const current of sort < string > ( directories , compareStringsCaseSensitive ) ) {
6692
+ const name = combinePaths ( path , current ) ;
6694
6693
const absoluteName = combinePaths ( absolutePath , current ) ;
6695
6694
if ( ( ! includeDirectoryRegex || includeDirectoryRegex . test ( absoluteName ) ) &&
6696
6695
( ! excludeRegex || ! excludeRegex . test ( absoluteName ) ) ) {
6697
- visitDirectory ( absoluteName , depth ) ;
6696
+ visitDirectory ( name , absoluteName , depth ) ;
6698
6697
}
6699
6698
}
6700
6699
}
6701
6700
}
6702
6701
6703
6702
/**
6704
6703
* Computes the unique non-wildcard base paths amongst the provided include patterns.
6705
- * @returns Absolute directory paths
6706
6704
*/
6707
- function getBasePaths ( absoluteTsconfigPath : string , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean ) : string [ ] {
6705
+ function getBasePaths ( path : string , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean ) : string [ ] {
6708
6706
// Storage for our results in the form of literal paths (e.g. the paths as written by the user).
6709
- const basePaths : string [ ] = [ absoluteTsconfigPath ] ;
6707
+ const basePaths : string [ ] = [ path ] ;
6710
6708
6711
6709
if ( includes ) {
6712
6710
// Storage for literal base paths amongst the include patterns.
6713
6711
const includeBasePaths : string [ ] = [ ] ;
6714
6712
for ( const include of includes ) {
6715
6713
// We also need to check the relative paths by converting them to absolute and normalizing
6716
6714
// in case they escape the base path (e.g "..\somedirectory")
6717
- const absoluteIncludePath : string = isRootedDiskPath ( include ) ? include : normalizePath ( combinePaths ( absoluteTsconfigPath , include ) ) ;
6715
+ const absolute : string = isRootedDiskPath ( include ) ? include : normalizePath ( combinePaths ( path , include ) ) ;
6718
6716
// Append the literal and canonical candidate base paths.
6719
- includeBasePaths . push ( getIncludeBasePath ( absoluteIncludePath ) ) ;
6717
+ includeBasePaths . push ( getIncludeBasePath ( absolute ) ) ;
6720
6718
}
6721
6719
6722
6720
// Sort the offsets array using either the literal or canonical path representations.
@@ -6725,7 +6723,7 @@ namespace ts {
6725
6723
// Iterate over each include base path and include unique base paths that are not a
6726
6724
// subpath of an existing base path
6727
6725
for ( const includeBasePath of includeBasePaths ) {
6728
- if ( every ( basePaths , basePath => ! containsPath ( basePath , includeBasePath , absoluteTsconfigPath , ! useCaseSensitiveFileNames ) ) ) {
6726
+ if ( every ( basePaths , basePath => ! containsPath ( basePath , includeBasePath , path , ! useCaseSensitiveFileNames ) ) ) {
6729
6727
basePaths . push ( includeBasePath ) ;
6730
6728
}
6731
6729
}
0 commit comments