@@ -540,8 +540,8 @@ interface Array<T> {}`
540
540
// Invoke directory and recursive directory watcher for the folder
541
541
// Here we arent invoking recursive directory watchers for the base folders
542
542
// since that is something we would want to do for both file as well as folder we are deleting
543
- invokeWatcherCallbacks ( this . watchedDirectories . get ( fileOrDirectory . path ) , cb => this . directoryCallback ( cb , relativePath ) ) ;
544
- invokeWatcherCallbacks ( this . watchedDirectoriesRecursive . get ( fileOrDirectory . path ) , cb => this . directoryCallback ( cb , relativePath ) ) ;
543
+ this . invokeWatchedDirectoriesCallback ( fileOrDirectory . fullPath , relativePath ) ;
544
+ this . invokeWatchedDirectoriesRecursiveCallback ( fileOrDirectory . fullPath , relativePath ) ;
545
545
}
546
546
547
547
if ( basePath !== fileOrDirectory . path ) {
@@ -554,9 +554,17 @@ interface Array<T> {}`
554
554
}
555
555
}
556
556
557
- private invokeFileWatcher ( fileFullPath : string , eventKind : FileWatcherEventKind ) {
558
- const callbacks = this . watchedFiles . get ( this . toPath ( fileFullPath ) ) ;
559
- invokeWatcherCallbacks ( callbacks , ( { cb } ) => cb ( fileFullPath , eventKind ) ) ;
557
+ // For overriding the methods
558
+ invokeWatchedDirectoriesCallback ( folderFullPath : string , relativePath : string ) {
559
+ invokeWatcherCallbacks ( this . watchedDirectories . get ( this . toPath ( folderFullPath ) ) , cb => this . directoryCallback ( cb , relativePath ) ) ;
560
+ }
561
+
562
+ invokeWatchedDirectoriesRecursiveCallback ( folderFullPath : string , relativePath : string ) {
563
+ invokeWatcherCallbacks ( this . watchedDirectoriesRecursive . get ( this . toPath ( folderFullPath ) ) , cb => this . directoryCallback ( cb , relativePath ) ) ;
564
+ }
565
+
566
+ invokeFileWatcher ( fileFullPath : string , eventKind : FileWatcherEventKind , useFileNameInCallback ?: boolean ) {
567
+ invokeWatcherCallbacks ( this . watchedFiles . get ( this . toPath ( fileFullPath ) ) , ( { cb, fileName } ) => cb ( useFileNameInCallback ? fileName : fileFullPath , eventKind ) ) ;
560
568
}
561
569
562
570
private getRelativePathToDirectory ( directoryFullPath : string , fileFullPath : string ) {
@@ -569,8 +577,8 @@ interface Array<T> {}`
569
577
private invokeDirectoryWatcher ( folderFullPath : string , fileName : string ) {
570
578
const relativePath = this . getRelativePathToDirectory ( folderFullPath , fileName ) ;
571
579
// Folder is changed when the directory watcher is invoked
572
- invokeWatcherCallbacks ( this . watchedFiles . get ( this . toPath ( folderFullPath ) ) , ( { cb , fileName } ) => cb ( fileName , FileWatcherEventKind . Changed ) ) ;
573
- invokeWatcherCallbacks ( this . watchedDirectories . get ( this . toPath ( folderFullPath ) ) , cb => this . directoryCallback ( cb , relativePath ) ) ;
580
+ this . invokeFileWatcher ( folderFullPath , FileWatcherEventKind . Changed , /*useFileNameInCallback*/ true ) ;
581
+ this . invokeWatchedDirectoriesCallback ( folderFullPath , relativePath ) ;
574
582
this . invokeRecursiveDirectoryWatcher ( folderFullPath , fileName ) ;
575
583
}
576
584
@@ -583,7 +591,7 @@ interface Array<T> {}`
583
591
*/
584
592
private invokeRecursiveDirectoryWatcher ( fullPath : string , fileName : string ) {
585
593
const relativePath = this . getRelativePathToDirectory ( fullPath , fileName ) ;
586
- invokeWatcherCallbacks ( this . watchedDirectoriesRecursive . get ( this . toPath ( fullPath ) ) , cb => this . directoryCallback ( cb , relativePath ) ) ;
594
+ this . invokeWatchedDirectoriesRecursiveCallback ( fullPath , relativePath ) ;
587
595
const basePath = getDirectoryPath ( fullPath ) ;
588
596
if ( this . getCanonicalFileName ( fullPath ) !== this . getCanonicalFileName ( basePath ) ) {
589
597
this . invokeRecursiveDirectoryWatcher ( basePath , fileName ) ;
0 commit comments