@@ -334,9 +334,10 @@ namespace ts {
334
334
/*@internal */
335
335
export interface RecursiveDirectoryWatcherHost {
336
336
watchDirectory : HostWatchDirectory ;
337
- getAccessileSortedChildDirectories ( path : string ) : ReadonlyArray < string > ;
337
+ getAccessibleSortedChildDirectories ( path : string ) : ReadonlyArray < string > ;
338
338
directoryExists ( dir : string ) : boolean ;
339
339
filePathComparer : Comparer < string > ;
340
+ realpath ( s : string ) : string ;
340
341
}
341
342
342
343
/**
@@ -392,9 +393,14 @@ namespace ts {
392
393
function watchChildDirectories ( parentDir : string , existingChildWatches : ChildWatches , callback : DirectoryWatcherCallback ) : ChildWatches {
393
394
let newChildWatches : DirectoryWatcher [ ] | undefined ;
394
395
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 ,
396
402
existingChildWatches ,
397
- ( child , childWatcher ) => host . filePathComparer ( getNormalizedAbsolutePath ( child , parentDir ) , childWatcher . dirName ) ,
403
+ ( child , childWatcher ) => host . filePathComparer ( child , childWatcher . dirName ) ,
398
404
createAndAddChildDirectoryWatcher ,
399
405
closeFileWatcher ,
400
406
addChildDirectoryWatcher
@@ -406,7 +412,7 @@ namespace ts {
406
412
* Create new childDirectoryWatcher and add it to the new ChildDirectoryWatcher list
407
413
*/
408
414
function createAndAddChildDirectoryWatcher ( childName : string ) {
409
- const result = createDirectoryWatcher ( getNormalizedAbsolutePath ( childName , parentDir ) , callback ) ;
415
+ const result = createDirectoryWatcher ( childName , callback ) ;
410
416
addChildDirectoryWatcher ( result ) ;
411
417
}
412
418
@@ -601,14 +607,7 @@ namespace ts {
601
607
exit ( exitCode ?: number ) : void {
602
608
process . exit ( exitCode ) ;
603
609
} ,
604
- realpath ( path : string ) : string {
605
- try {
606
- return _fs . realpathSync ( path ) ;
607
- }
608
- catch {
609
- return path ;
610
- }
611
- } ,
610
+ realpath,
612
611
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 ) ) ,
613
612
tryEnableSourceMapsForHost ( ) {
614
613
try {
@@ -699,8 +698,9 @@ namespace ts {
699
698
const watchDirectoryRecursively = createRecursiveDirectoryWatcher ( {
700
699
filePathComparer : useCaseSensitiveFileNames ? compareStringsCaseSensitive : compareStringsCaseInsensitive ,
701
700
directoryExists,
702
- getAccessileSortedChildDirectories : path => getAccessibleFileSystemEntries ( path ) . directories ,
703
- watchDirectory
701
+ getAccessibleSortedChildDirectories : path => getAccessibleFileSystemEntries ( path ) . directories ,
702
+ watchDirectory,
703
+ realpath
704
704
} ) ;
705
705
706
706
return ( directoryName , callback , recursive ) => {
@@ -1043,6 +1043,15 @@ namespace ts {
1043
1043
return filter < string > ( _fs . readdirSync ( path ) , dir => fileSystemEntryExists ( combinePaths ( path , dir ) , FileSystemEntryKind . Directory ) ) ;
1044
1044
}
1045
1045
1046
+ function realpath ( path : string ) : string {
1047
+ try {
1048
+ return _fs . realpathSync ( path ) ;
1049
+ }
1050
+ catch {
1051
+ return path ;
1052
+ }
1053
+ }
1054
+
1046
1055
function getModifiedTime ( path : string ) {
1047
1056
try {
1048
1057
return _fs . statSync ( path ) . mtime ;
0 commit comments