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