@@ -330,7 +330,7 @@ describe('readdirp', () => {
330
330
entry . should . containSubset ( formatEntry ( created [ index ] , currPath ) )
331
331
) ;
332
332
} ) ;
333
- it ( 'should emit warning for missing file ' , async ( ) => {
333
+ it ( 'should emit warning for missing directory ' , async ( ) => {
334
334
await beforeEach ( ) ;
335
335
// readdirp() is initialized on some big root directory
336
336
// readdirp() receives path a/b/c to its queue
@@ -354,6 +354,33 @@ describe('readdirp', () => {
354
354
await Promise . race ( [ waitForEnd ( stream ) , delay ( 2000 ) ] ) ;
355
355
isWarningCalled . should . equals ( true ) ;
356
356
} ) ; //.timeout(4000);
357
+ it ( 'should emit warning for missing file' , async ( ) => {
358
+ await beforeEach ( ) ;
359
+ // readdirp() is initialized on some big root directory
360
+ // readdirp() receives files f1, f2, f3 to its queue
361
+ // readdirp is reading something else
362
+ // f1 gets deleted, so stat()-ting f1 would now emit enoent
363
+ // We should emit warnings for this case and properly process f2 and f3
364
+ // this.timeout(4000);
365
+ await touch ( [ 'f1' , 'f2' , 'f3' ] ) ;
366
+ let isWarningCalled = false ;
367
+ const stream = readdirp ( currPath , { type : 'all' , highWaterMark : 1 , alwaysStat : true } ) ;
368
+ stream . on ( 'warn' , ( warning ) => {
369
+ warning . should . be . an . instanceof ( Error ) ;
370
+ warning . code . should . equals ( 'ENOENT' ) ;
371
+ isWarningCalled = true ;
372
+ } ) ;
373
+ await delay ( 1000 ) ;
374
+ await rm ( sysPath . join ( currPath , 'f1' ) , { recursive : true } ) ;
375
+ const detected = [ ] ;
376
+ stream . on ( 'data' , ( file ) => {
377
+ detected . push ( file . path ) ;
378
+ } ) ;
379
+ await Promise . race ( [ waitForEnd ( stream ) , delay ( 2000 ) ] ) ;
380
+
381
+ chai . expect ( detected ) . to . deep . equal ( [ 'f2' , 'f3' ] ) ;
382
+ isWarningCalled . should . equals ( true ) ;
383
+ } ) ;
357
384
it ( 'should emit warning for file with strict permission' , async ( ) => {
358
385
// Windows doesn't throw permission error if you access permitted directory
359
386
if ( isWindows ) {
0 commit comments