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