@@ -423,6 +423,8 @@ namespace ts {
423
423
export interface WatchFactoryHost {
424
424
watchFile ( path : string , callback : FileWatcherCallback , pollingInterval ?: number , options ?: WatchOptions ) : FileWatcher ;
425
425
watchDirectory ( path : string , callback : DirectoryWatcherCallback , recursive ?: boolean , options ?: WatchOptions ) : FileWatcher ;
426
+ getCurrentDirectory ?( ) : string ;
427
+ useCaseSensitiveFileNames : boolean | ( ( ) => boolean ) ;
426
428
}
427
429
428
430
export interface WatchFactory < X , Y = undefined > {
@@ -445,12 +447,52 @@ namespace ts {
445
447
watchDirectory : createTriggerLoggingAddWatch ( "watchDirectory" )
446
448
} :
447
449
undefined ;
448
- return watchLogLevel === WatchLogLevel . Verbose ?
450
+ const factory = watchLogLevel === WatchLogLevel . Verbose ?
449
451
{
450
452
watchFile : createFileWatcherWithLogging ,
451
453
watchDirectory : createDirectoryWatcherWithLogging
452
454
} :
453
455
triggerInvokingFactory || plainInvokeFactory ;
456
+ const excludeWatcherFactory = watchLogLevel === WatchLogLevel . Verbose ?
457
+ createExcludeWatcherWithLogging :
458
+ returnNoopFileWatcher ;
459
+
460
+ return {
461
+ watchFile : createExcludeHandlingAddWatch ( "watchFile" ) ,
462
+ watchDirectory : createExcludeHandlingAddWatch ( "watchDirectory" )
463
+ } ;
464
+
465
+ function createExcludeHandlingAddWatch < T extends keyof WatchFactory < X , Y > > ( key : T ) : WatchFactory < X , Y > [ T ] {
466
+ return (
467
+ file : string ,
468
+ cb : FileWatcherCallback | DirectoryWatcherCallback ,
469
+ flags : PollingInterval | WatchDirectoryFlags ,
470
+ options : WatchOptions | undefined ,
471
+ detailInfo1 : X ,
472
+ detailInfo2 ?: Y
473
+ ) => ! matchesExclude ( file , key === "watchFile" ? options ?. excludeFiles : options ?. excludeDirectories , useCaseSensitiveFileNames ( ) , host . getCurrentDirectory ?.( ) || "" ) ?
474
+ factory [ key ] . call ( /*thisArgs*/ undefined , file , cb , flags , options , detailInfo1 , detailInfo2 ) :
475
+ excludeWatcherFactory ( file , flags , options , detailInfo1 , detailInfo2 ) ;
476
+ }
477
+
478
+ function useCaseSensitiveFileNames ( ) {
479
+ return typeof host . useCaseSensitiveFileNames === "boolean" ?
480
+ host . useCaseSensitiveFileNames :
481
+ host . useCaseSensitiveFileNames ( ) ;
482
+ }
483
+
484
+ function createExcludeWatcherWithLogging (
485
+ file : string ,
486
+ flags : PollingInterval | WatchDirectoryFlags ,
487
+ options : WatchOptions | undefined ,
488
+ detailInfo1 : X ,
489
+ detailInfo2 ?: Y
490
+ ) {
491
+ log ( `ExcludeWatcher:: Added:: ${ getWatchInfo ( file , flags , options , detailInfo1 , detailInfo2 , getDetailWatchInfo ) } ` ) ;
492
+ return {
493
+ close : ( ) => log ( `ExcludeWatcher:: Close:: ${ getWatchInfo ( file , flags , options , detailInfo1 , detailInfo2 , getDetailWatchInfo ) } ` )
494
+ } ;
495
+ }
454
496
455
497
function createFileWatcherWithLogging (
456
498
file : string ,
@@ -496,7 +538,7 @@ namespace ts {
496
538
} ;
497
539
}
498
540
499
- function createTriggerLoggingAddWatch < T extends keyof WatchFactory < X , Y > > ( key : T , ) : WatchFactory < X , Y > [ T ] {
541
+ function createTriggerLoggingAddWatch < T extends keyof WatchFactory < X , Y > > ( key : T ) : WatchFactory < X , Y > [ T ] {
500
542
return (
501
543
file : string ,
502
544
cb : FileWatcherCallback | DirectoryWatcherCallback ,
0 commit comments