@@ -2143,6 +2143,47 @@ const runTests = (baseopts) => {
21432143 watcher . close ( ) ;
21442144 }
21452145 } ) ;
2146+
2147+ it ( 'should detect changes to symlink folders, even if they were deleted before' , async ( ) => {
2148+ const id = subdirId . toString ( ) ;
2149+ const relativeWatcherDir = sysPath . join ( FIXTURES_PATH_REL , id , 'test' ) ;
2150+ const linkedRelativeWatcherDir = sysPath . join ( FIXTURES_PATH_REL , id , 'test-link' ) ;
2151+ await fs_symlink ( sysPath . resolve ( relativeWatcherDir ) , linkedRelativeWatcherDir ) ;
2152+ const watcher = chokidar . watch ( linkedRelativeWatcherDir , {
2153+ persistent : true ,
2154+ } ) ;
2155+ try {
2156+ const events = [ ] ;
2157+ watcher . on ( 'all' , ( event , path ) =>
2158+ events . push ( `[ALL] ${ event } : ${ path } ` )
2159+ ) ;
2160+ const testSubDir = sysPath . join ( relativeWatcherDir , 'dir' ) ;
2161+ const testSubDirFile = sysPath . join ( relativeWatcherDir , 'dir' , 'file' ) ;
2162+
2163+ // Command sequence from https://github.com/paulmillr/chokidar/issues/1042.
2164+ await delay ( ) ;
2165+ await fs_mkdir ( relativeWatcherDir ) ;
2166+ await fs_mkdir ( testSubDir ) ;
2167+ // The following delay is essential otherwise the call of mkdir and rmdir will be equalize
2168+ await delay ( 300 ) ;
2169+ await fs_rmdir ( testSubDir ) ;
2170+ // The following delay is essential otherwise the call of rmdir and mkdir will be equalize
2171+ await delay ( 300 ) ;
2172+ await fs_mkdir ( testSubDir ) ;
2173+ await write ( testSubDirFile , '' ) ;
2174+ await delay ( 300 ) ;
2175+
2176+ chai . assert . deepStrictEqual ( events , [
2177+ `[ALL] addDir: ${ sysPath . join ( 'test-fixtures' , id , 'test-link' ) } ` ,
2178+ `[ALL] addDir: ${ sysPath . join ( 'test-fixtures' , id , 'test-link' , 'dir' ) } ` ,
2179+ `[ALL] unlinkDir: ${ sysPath . join ( 'test-fixtures' , id , 'test-link' , 'dir' ) } ` ,
2180+ `[ALL] addDir: ${ sysPath . join ( 'test-fixtures' , id , 'test-link' , 'dir' ) } ` ,
2181+ `[ALL] add: ${ sysPath . join ( 'test-fixtures' , id , 'test-link' , 'dir' , 'file' ) } ` ,
2182+ ] ) ;
2183+ } finally {
2184+ watcher . close ( ) ;
2185+ }
2186+ } ) ;
21462187 } ) ;
21472188} ;
21482189
0 commit comments