@@ -334,9 +334,10 @@ namespace ts {
334334 /*@internal */
335335 export interface RecursiveDirectoryWatcherHost {
336336 watchDirectory : HostWatchDirectory ;
337- getAccessileSortedChildDirectories ( path : string ) : ReadonlyArray < string > ;
337+ getAccessibleSortedChildDirectories ( path : string ) : ReadonlyArray < string > ;
338338 directoryExists ( dir : string ) : boolean ;
339339 filePathComparer : Comparer < string > ;
340+ realpath ( s : string ) : string ;
340341 }
341342
342343 /**
@@ -392,9 +393,14 @@ namespace ts {
392393 function watchChildDirectories ( parentDir : string , existingChildWatches : ChildWatches , callback : DirectoryWatcherCallback ) : ChildWatches {
393394 let newChildWatches : DirectoryWatcher [ ] | undefined ;
394395 enumerateInsertsAndDeletes < string , DirectoryWatcher > (
395- host . directoryExists ( parentDir ) ? host . getAccessileSortedChildDirectories ( parentDir ) : emptyArray ,
396+ host . directoryExists ( parentDir ) ? mapDefined ( host . getAccessibleSortedChildDirectories ( parentDir ) , child => {
397+ const childFullName = getNormalizedAbsolutePath ( child , parentDir ) ;
398+ // Filter our the symbolic link directories since those arent included in recursive watch
399+ // which is same behaviour when recursive: true is passed to fs.watch
400+ return host . filePathComparer ( childFullName , host . realpath ( childFullName ) ) === Comparison . EqualTo ? childFullName : undefined ;
401+ } ) : emptyArray ,
396402 existingChildWatches ,
397- ( child , childWatcher ) => host . filePathComparer ( getNormalizedAbsolutePath ( child , parentDir ) , childWatcher . dirName ) ,
403+ ( child , childWatcher ) => host . filePathComparer ( child , childWatcher . dirName ) ,
398404 createAndAddChildDirectoryWatcher ,
399405 closeFileWatcher ,
400406 addChildDirectoryWatcher
@@ -406,7 +412,7 @@ namespace ts {
406412 * Create new childDirectoryWatcher and add it to the new ChildDirectoryWatcher list
407413 */
408414 function createAndAddChildDirectoryWatcher ( childName : string ) {
409- const result = createDirectoryWatcher ( getNormalizedAbsolutePath ( childName , parentDir ) , callback ) ;
415+ const result = createDirectoryWatcher ( childName , callback ) ;
410416 addChildDirectoryWatcher ( result ) ;
411417 }
412418
@@ -601,14 +607,7 @@ namespace ts {
601607 exit ( exitCode ?: number ) : void {
602608 process . exit ( exitCode ) ;
603609 } ,
604- realpath ( path : string ) : string {
605- try {
606- return _fs . realpathSync ( path ) ;
607- }
608- catch {
609- return path ;
610- }
611- } ,
610+ realpath,
612611 debugMode : some ( < string [ ] > process . execArgv , arg => / ^ - - ( i n s p e c t | d e b u g ) ( - b r k ) ? ( = \d + ) ? $ / i. test ( arg ) ) ,
613612 tryEnableSourceMapsForHost ( ) {
614613 try {
@@ -699,8 +698,9 @@ namespace ts {
699698 const watchDirectoryRecursively = createRecursiveDirectoryWatcher ( {
700699 filePathComparer : useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive ,
701700 directoryExists,
702- getAccessileSortedChildDirectories : path => getAccessibleFileSystemEntries ( path ) . directories ,
703- watchDirectory
701+ getAccessibleSortedChildDirectories : path => getAccessibleFileSystemEntries ( path ) . directories ,
702+ watchDirectory,
703+ realpath
704704 } ) ;
705705
706706 return ( directoryName , callback , recursive ) => {
@@ -1043,6 +1043,15 @@ namespace ts {
10431043 return filter < string > ( _fs . readdirSync ( path ) , dir => fileSystemEntryExists ( combinePaths ( path , dir ) , FileSystemEntryKind . Directory ) ) ;
10441044 }
10451045
1046+ function realpath ( path : string ) : string {
1047+ try {
1048+ return _fs . realpathSync ( path ) ;
1049+ }
1050+ catch {
1051+ return path ;
1052+ }
1053+ }
1054+
10461055 function getModifiedTime ( path : string ) {
10471056 try {
10481057 return _fs . statSync ( path ) . mtime ;
0 commit comments