diff options
Diffstat (limited to 'deps/npm/node_modules/mississippi/node_modules/end-of-stream/index.js')
-rw-r--r-- | deps/npm/node_modules/mississippi/node_modules/end-of-stream/index.js | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/deps/npm/node_modules/mississippi/node_modules/end-of-stream/index.js b/deps/npm/node_modules/mississippi/node_modules/end-of-stream/index.js index b3a9068634..be426c227c 100644 --- a/deps/npm/node_modules/mississippi/node_modules/end-of-stream/index.js +++ b/deps/npm/node_modules/mississippi/node_modules/end-of-stream/index.js @@ -39,6 +39,10 @@ var eos = function(stream, opts, callback) { callback.call(stream, exitCode ? new Error('exited with error code: ' + exitCode) : null); }; + var onerror = function(err) { + callback.call(stream, err); + }; + var onclose = function() { if (readable && !(rs && rs.ended)) return callback.call(stream, new Error('premature close')); if (writable && !(ws && ws.ended)) return callback.call(stream, new Error('premature close')); @@ -62,7 +66,7 @@ var eos = function(stream, opts, callback) { stream.on('end', onend); stream.on('finish', onfinish); - if (opts.error !== false) stream.on('error', callback); + if (opts.error !== false) stream.on('error', onerror); stream.on('close', onclose); return function() { @@ -75,7 +79,7 @@ var eos = function(stream, opts, callback) { stream.removeListener('finish', onfinish); stream.removeListener('exit', onexit); stream.removeListener('end', onend); - stream.removeListener('error', callback); + stream.removeListener('error', onerror); stream.removeListener('close', onclose); }; }; |