@@ -6629,7 +6629,7 @@ namespace ts {
66296629 includeFilePattern : getRegularExpressionForWildcard ( includes , absolutePath , "files" ) ,
66306630 includeDirectoryPattern : getRegularExpressionForWildcard ( includes , absolutePath , "directories" ) ,
66316631 excludePattern : getRegularExpressionForWildcard ( excludes , absolutePath , "exclude" ) ,
6632- basePaths : getBasePaths ( absolutePath , includes , useCaseSensitiveFileNames )
6632+ basePaths : getBasePaths ( path , includes , useCaseSensitiveFileNames )
66336633 } ;
66346634 }
66356635
@@ -6638,7 +6638,7 @@ namespace ts {
66386638 }
66396639
66406640 /** @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 [ ] {
66426642 path = normalizePath ( path ) ;
66436643 currentDirectory = normalizePath ( currentDirectory ) ;
66446644
@@ -6653,22 +6653,20 @@ namespace ts {
66536653 const results : string [ ] [ ] = includeFileRegexes ? includeFileRegexes . map ( ( ) => [ ] ) : [ [ ] ] ;
66546654 const visited = new Map < string , true > ( ) ;
66556655 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 ) ;
66606658 }
66616659
66626660 return flatten ( results ) ;
66636661
6664- function visitDirectory ( absolutePath : string , depth : number | undefined ) {
6662+ function visitDirectory ( path : string , absolutePath : string , depth : number | undefined ) {
66656663 const canonicalPath = toCanonical ( realpath ( absolutePath ) ) ;
66666664 if ( visited . has ( canonicalPath ) ) return ;
66676665 visited . set ( canonicalPath , true ) ;
6668- const { files, directories } = getFileSystemEntries ( absolutePath ) ;
6666+ const { files, directories } = getFileSystemEntries ( path ) ;
66696667
66706668 for ( const current of sort < string > ( files , compareStringsCaseSensitive ) ) {
6671- const name = combinePaths ( absolutePath , current ) ;
6669+ const name = combinePaths ( path , current ) ;
66726670 const absoluteName = combinePaths ( absolutePath , current ) ;
66736671 if ( extensions && ! fileExtensionIsOneOf ( name , extensions ) ) continue ;
66746672 if ( excludeRegex && excludeRegex . test ( absoluteName ) ) continue ;
@@ -6691,32 +6689,32 @@ namespace ts {
66916689 }
66926690
66936691 for ( const current of sort < string > ( directories , compareStringsCaseSensitive ) ) {
6692+ const name = combinePaths ( path , current ) ;
66946693 const absoluteName = combinePaths ( absolutePath , current ) ;
66956694 if ( ( ! includeDirectoryRegex || includeDirectoryRegex . test ( absoluteName ) ) &&
66966695 ( ! excludeRegex || ! excludeRegex . test ( absoluteName ) ) ) {
6697- visitDirectory ( absoluteName , depth ) ;
6696+ visitDirectory ( name , absoluteName , depth ) ;
66986697 }
66996698 }
67006699 }
67016700 }
67026701
67036702 /**
67046703 * Computes the unique non-wildcard base paths amongst the provided include patterns.
6705- * @returns Absolute directory paths
67066704 */
6707- function getBasePaths ( absoluteTsconfigPath : string , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean ) : string [ ] {
6705+ function getBasePaths ( path : string , includes : readonly string [ ] | undefined , useCaseSensitiveFileNames : boolean ) : string [ ] {
67086706 // 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 ] ;
67106708
67116709 if ( includes ) {
67126710 // Storage for literal base paths amongst the include patterns.
67136711 const includeBasePaths : string [ ] = [ ] ;
67146712 for ( const include of includes ) {
67156713 // We also need to check the relative paths by converting them to absolute and normalizing
67166714 // 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 ) ) ;
67186716 // Append the literal and canonical candidate base paths.
6719- includeBasePaths . push ( getIncludeBasePath ( absoluteIncludePath ) ) ;
6717+ includeBasePaths . push ( getIncludeBasePath ( absolute ) ) ;
67206718 }
67216719
67226720 // Sort the offsets array using either the literal or canonical path representations.
@@ -6725,7 +6723,7 @@ namespace ts {
67256723 // Iterate over each include base path and include unique base paths that are not a
67266724 // subpath of an existing base path
67276725 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 ) ) ) {
67296727 basePaths . push ( includeBasePath ) ;
67306728 }
67316729 }
0 commit comments