@@ -206,8 +206,6 @@ Deps.prototype.readFile = function (file, id, pkg) {
206
206
var rs = fs . createReadStream ( file , {
207
207
encoding : 'utf8'
208
208
} ) ;
209
- rs . on ( 'error' , function ( err ) { self . emit ( 'error' , err ) } ) ;
210
- this . emit ( 'file' , file , id ) ;
211
209
return rs ;
212
210
} ;
213
211
@@ -235,7 +233,9 @@ Deps.prototype.getTransforms = function (file, pkg, opts) {
235
233
236
234
for ( var i = 0 ; i < transforms . length ; i ++ ) ( function ( i ) {
237
235
makeTransform ( transforms [ i ] , function ( err , trs ) {
238
- if ( err ) return self . emit ( 'error' , err )
236
+ if ( err ) {
237
+ return dup . emit ( 'error' , err ) ;
238
+ }
239
239
streams [ i ] = trs ;
240
240
if ( -- pending === 0 ) done ( ) ;
241
241
} ) ;
@@ -247,7 +247,7 @@ Deps.prototype.getTransforms = function (file, pkg, opts) {
247
247
middle . on ( 'error' , function ( err ) {
248
248
err . message += ' while parsing file: ' + file ;
249
249
if ( ! err . filename ) err . filename = file ;
250
- self . emit ( 'error' , err ) ;
250
+ dup . emit ( 'error' , err ) ;
251
251
} ) ;
252
252
input . pipe ( middle ) . pipe ( output ) ;
253
253
}
@@ -346,6 +346,9 @@ Deps.prototype.walk = function (id, parent, cb) {
346
346
file = rec . file ;
347
347
348
348
var ts = self . getTransforms ( file , pkg ) ;
349
+ ts . on ( 'error' , function ( err ) {
350
+ self . emit ( 'error' , err ) ;
351
+ } ) ;
349
352
ts . pipe ( concat ( function ( body ) {
350
353
rec . source = body . toString ( 'utf8' ) ;
351
354
fromSource ( file , rec . source , pkg ) ;
@@ -368,6 +371,9 @@ Deps.prototype.walk = function (id, parent, cb) {
368
371
369
372
if ( rec . source ) {
370
373
var ts = self . getTransforms ( file , pkg ) ;
374
+ ts . on ( 'error' , function ( err ) {
375
+ self . emit ( 'error' , err ) ;
376
+ } ) ;
371
377
ts . pipe ( concat ( function ( body ) {
372
378
rec . source = body . toString ( 'utf8' ) ;
373
379
fromSource ( file , rec . source , pkg ) ;
@@ -379,6 +385,7 @@ Deps.prototype.walk = function (id, parent, cb) {
379
385
if ( c ) return fromDeps ( file , c . source , c . package , fakePath , Object . keys ( c . deps ) ) ;
380
386
381
387
self . persistentCache ( file , id , pkg , persistentCacheFallback , function ( err , c ) {
388
+ self . emit ( 'file' , file , id ) ;
382
389
if ( err ) {
383
390
self . emit ( 'error' , err ) ;
384
391
return ;
@@ -387,12 +394,13 @@ Deps.prototype.walk = function (id, parent, cb) {
387
394
} ) ;
388
395
389
396
function persistentCacheFallback ( dataAsString , cb ) {
390
- var stream = dataAsString ? toStream ( dataAsString ) : self . readFile ( file , id , pkg ) ;
397
+ var stream = dataAsString ? toStream ( dataAsString ) : self . readFile ( file , id , pkg ) . on ( 'error' , cb ) ;
391
398
stream
392
399
. pipe ( self . getTransforms ( fakePath || file , pkg , {
393
400
builtin : builtin ,
394
401
inNodeModules : parent . inNodeModules
395
402
} ) )
403
+ . on ( 'error' , cb )
396
404
. pipe ( concat ( function ( body ) {
397
405
var src = body . toString ( 'utf8' ) ;
398
406
var deps = getDeps ( file , src ) ;
0 commit comments