File tree 2 files changed +21
-2
lines changed
2 files changed +21
-2
lines changed Original file line number Diff line number Diff line change @@ -163,8 +163,6 @@ function File (options) {
163
163
if ( self . buffers . length > 0 ) {
164
164
stream . Stream . prototype . pipe . call ( self , fs . createWriteStream ( self . path ) )
165
165
} else if ( self . listeners ( 'data' ) . length > 0 ) {
166
- fs . createReadStream ( self . path ) . pipe ( self . dest )
167
- } else {
168
166
fs . createReadStream ( self . path ) . pipe ( self )
169
167
}
170
168
}
Original file line number Diff line number Diff line change @@ -207,4 +207,25 @@ function testhttp () {
207
207
}
208
208
testhttp ( )
209
209
210
+ function testManualRead ( ) {
211
+ var stream = filed ( path . join ( __dirname , 'fixture.txt' ) )
212
+
213
+ var expected =
214
+ `abc
215
+ xyz
216
+ `
217
+ var body = Buffer . from ( '' )
218
+
219
+ stream . on ( 'data' , function ( chunk ) { body = Buffer . concat ( [ body , chunk ] ) } )
220
+ stream . on ( 'error' , function ( err ) { throw err } )
221
+ stream . on ( 'end' , function ( ) {
222
+ var actual = body . toString ( 'utf8' )
223
+ if ( actual !== expected ) {
224
+ throw new Error ( `Expected\n\n${ actual } \n\nto equal\n\n${ expected } ` )
225
+ }
226
+ else console . log ( 'Passed testManualRead' )
227
+ } )
228
+ }
229
+ testManualRead ( )
230
+
210
231
process . on ( 'exit' , function ( ) { console . log ( 'All tests passed.' ) } )
You can’t perform that action at this time.
0 commit comments