@@ -6615,7 +6615,7 @@ namespace ts {
66156615 includeFilePattern : getRegularExpressionForWildcard ( includes , absolutePath , "files" ) ,
66166616 includeDirectoryPattern : getRegularExpressionForWildcard ( includes , absolutePath , "directories" ) ,
66176617 excludePattern : getRegularExpressionForWildcard ( excludes , absolutePath , "exclude" ) ,
6618- basePaths : getBasePaths ( absolutePath , includes , useCaseSensitiveFileNames )
6618+ basePaths : getBasePaths ( path , includes , useCaseSensitiveFileNames )
66196619 } ;
66206620 }
66216621
@@ -6624,7 +6624,7 @@ namespace ts {
66246624 }
66256625
66266626 /** @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 [ ] {
66286628 path = normalizePath ( path ) ;
66296629 currentDirectory = normalizePath ( currentDirectory ) ;
66306630
@@ -6639,22 +6639,20 @@ namespace ts {
66396639 const results : string [ ] [ ] = includeFileRegexes ? includeFileRegexes . map ( ( ) => [ ] ) : [ [ ] ] ;
66406640 const visited = new Map < string , true > ( ) ;
66416641 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 ) ;
66466644 }
66476645
66486646 return flatten ( results ) ;
66496647
6650- function visitDirectory ( absolutePath : string , depth : number | undefined ) {
6648+ function visitDirectory ( path : string , absolutePath : string , depth : number | undefined ) {
66516649 const canonicalPath = toCanonical ( realpath ( absolutePath ) ) ;
66526650 if ( visited . has ( canonicalPath ) ) return ;
66536651 visited . set ( canonicalPath , true ) ;
6654- const { files, directories } = getFileSystemEntries ( absolutePath ) ;
6652+ const { files, directories } = getFileSystemEntries ( path ) ;
66556653
66566654 for ( const current of sort < string > ( files , compareStringsCaseSensitive ) ) {
6657- const name = combinePaths ( absolutePath , current ) ;
6655+ const name = combinePaths ( path , current ) ;
66586656 const absoluteName = combinePaths ( absolutePath , current ) ;
66596657 if ( extensions && ! fileExtensionIsOneOf ( name , extensions ) ) continue ;
66606658 if ( excludeRegex && excludeRegex . test ( absoluteName ) ) continue ;
@@ -6677,32 +6675,32 @@ namespace ts {
66776675 }
66786676
66796677 for ( const current of sort < string > ( directories , compareStringsCaseSensitive ) ) {
6678+ const name = combinePaths ( path , current ) ;
66806679 const absoluteName = combinePaths ( absolutePath , current ) ;
66816680 if ( ( ! includeDirectoryRegex || includeDirectoryRegex . test ( absoluteName ) ) &&
66826681 ( ! excludeRegex || ! excludeRegex . test ( absoluteName ) ) ) {
6683- visitDirectory ( absoluteName , depth ) ;
6682+ visitDirectory ( name , absoluteName , depth ) ;
66846683 }
66856684 }
66866685 }
66876686 }
66886687
66896688 /**
66906689 * Computes the unique non-wildcard base paths amongst the provided include patterns.
6691- * @returns Absolute directory paths
66926690 */
6693- function getBasePaths ( absoluteTsconfigPath : string , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean ) : string [ ] {
6691+ function getBasePaths ( path : string , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean ) : string [ ] {
66946692 // 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 ] ;
66966694
66976695 if ( includes ) {
66986696 // Storage for literal base paths amongst the include patterns.
66996697 const includeBasePaths : string [ ] = [ ] ;
67006698 for ( const include of includes ) {
67016699 // We also need to check the relative paths by converting them to absolute and normalizing
67026700 // 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 ) ) ;
67046702 // Append the literal and canonical candidate base paths.
6705- includeBasePaths . push ( getIncludeBasePath ( absoluteIncludePath ) ) ;
6703+ includeBasePaths . push ( getIncludeBasePath ( absolute ) ) ;
67066704 }
67076705
67086706 // Sort the offsets array using either the literal or canonical path representations.
@@ -6711,7 +6709,7 @@ namespace ts {
67116709 // Iterate over each include base path and include unique base paths that are not a
67126710 // subpath of an existing base path
67136711 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 ) ) ) {
67156713 basePaths . push ( includeBasePath ) ;
67166714 }
67176715 }
0 commit comments