File tree 2 files changed +28
-0
lines changed
2 files changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ function sink(stream) {
11
11
} ) ;
12
12
13
13
return function ( ) {
14
+ // Respect readable listeners on the underlying stream
15
+ if ( stream . listeners ( 'readable' ) . length > 0 ) {
16
+ return ;
17
+ }
18
+
14
19
stream . pipe ( sinkStream ) ;
15
20
} ;
16
21
}
Original file line number Diff line number Diff line change @@ -1337,6 +1337,29 @@ describe('dest stream', function() {
1337
1337
. pipe ( slowCountFiles ) ;
1338
1338
} ) ;
1339
1339
1340
+ it ( 'should respect readable listeners on destination stream' , function ( done ) {
1341
+ var srcPath = path . join ( __dirname , './fixtures/test.coffee' ) ;
1342
+ var srcStream = vfs . src ( srcPath ) ;
1343
+ var destStream = vfs . dest ( './out-fixtures/' , { cwd : __dirname } ) ;
1344
+
1345
+ srcStream
1346
+ . pipe ( destStream ) ;
1347
+
1348
+ var readables = 0 ;
1349
+ destStream . on ( 'readable' , function ( ) {
1350
+ var data = destStream . read ( ) ;
1351
+
1352
+ if ( data == null ) {
1353
+ // Stream ended
1354
+ readables . should . equal ( 1 ) ;
1355
+ done ( ) ;
1356
+ } else {
1357
+ // New data
1358
+ readables ++ ;
1359
+ }
1360
+ } ) ;
1361
+ } ) ;
1362
+
1340
1363
it ( 'should pass options to through2' , function ( done ) {
1341
1364
var srcPath = path . join ( __dirname , './fixtures/test.coffee' ) ;
1342
1365
var content = fs . readFileSync ( srcPath ) ;
You can’t perform that action at this time.
0 commit comments