@@ -410,30 +410,19 @@ namespace ts {
410410 watchDirectory : ( path , callback , recursive ) => {
411411 // Node 4.0 `fs.watch` function supports the "recursive" option on both OSX and Windows
412412 // (ref: https://github.com/nodejs/node/pull/2649 and https://github.com/Microsoft/TypeScript/issues/4643)
413- // therefore if the current node.js version is newer than 4, use `fs.watch` instead.
414-
415- // In watchDirectory we only care about adding and removing files (when event name is
416- // "rename"); changes made within files are handled by corresponding fileWatchers (when
417- // event name is "change")
418-
419- if ( isNode4OrLater ( ) ) {
420- return _fs . watch (
421- path ,
422- { persisten : true , recursive : ! ! recursive } ,
423- ( eventName : string , relativeFileName : string ) => {
424- if ( eventName == "rename" ) {
425- // when deleting a file, the passed baseFileName is null
426- callback ( relativeFileName == null ? null : normalizePath ( ts . combinePaths ( path , relativeFileName ) ) )
427- } ;
428- }
429- ) ;
430- }
431-
432- // If Node version is older than 4.0, the "recursive" parameter will be ignored
433- var watchedFile = watchedFileSet . addFile ( path , callback ) ;
434- return {
435- close : ( ) => watchedFileSet . removeFile ( watchedFile )
436- }
413+ return _fs . watch (
414+ path ,
415+ { persisten : true , recursive : ! ! recursive } ,
416+ ( eventName : string , relativeFileName : string ) => {
417+ // In watchDirectory we only care about adding and removing files (when event name is
418+ // "rename"); changes made within files are handled by corresponding fileWatchers (when
419+ // event name is "change")
420+ if ( eventName == "rename" ) {
421+ // When deleting a file, the passed baseFileName is null
422+ callback ( relativeFileName == null ? null : normalizePath ( ts . combinePaths ( path , relativeFileName ) ) )
423+ } ;
424+ }
425+ ) ;
437426 } ,
438427 resolvePath : function ( path : string ) : string {
439428 return _path . resolve ( path ) ;
0 commit comments