@@ -71,13 +71,13 @@ export type WatchDirOptions = {
7171 iterOnLinux ?: boolean
7272}
7373
74- function watchDir ( dir : string , cb : WatchDirHandler ) : void
75- function watchDir ( dir : string , options : WatchDirOptions , cb : WatchDirHandler ) : void
74+ function watchDir ( dir : string , cb : WatchDirHandler ) : _fs . FSWatcher | _fs . FSWatcher [ ]
75+ function watchDir ( dir : string , options : WatchDirOptions , cb : WatchDirHandler ) : _fs . FSWatcher | _fs . FSWatcher [ ]
7676function watchDir (
7777 dir : string ,
7878 options ?: WatchDirOptions | WatchDirHandler ,
7979 cb ?: WatchDirHandler ,
80- ) : void {
80+ ) : _fs . FSWatcher | _fs . FSWatcher [ ] {
8181 if ( Is . fn ( options ) ) {
8282 cb = options as any
8383 options = void 0
@@ -92,9 +92,10 @@ function watchDir(
9292 cb = cb && debounce ( cb , options . threshold )
9393 }
9494 if ( process . platform === 'linux' && options . iterOnLinux ) {
95+ let watches :_fs . FSWatcher [ ] = [ ]
9596 // tslint:disable-next-line:no-floating-promises
9697 fsExtra . iter ( dir , ( file ) => {
97- _fs . watch (
98+ let w = _fs . watch (
9899 file ,
99100 {
100101 recursive : false ,
@@ -103,9 +104,11 @@ function watchDir(
103104 } ,
104105 cb ,
105106 )
107+ watches . push ( w )
106108 } )
109+ return watches
107110 } else {
108- _fs . watch ( dir , { recursive : true , persistent : options . persistent } , cb )
111+ return _fs . watch ( dir , { recursive : true , persistent : options . persistent } , cb )
109112 }
110113}
111114
0 commit comments