Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRebecca Turner <me@re-becca.org>2015-06-27 07:58:24 +0300
committerRebecca Turner <me@re-becca.org>2015-07-01 14:05:44 +0300
commit57c3cea9ed98d9d4185afb4fcd45bb5ed30a62e3 (patch)
tree63548f9d59ef3570856099e3dd93f281944c8459
parentc1312b8a0582895b744310867e6667efce97e4df (diff)
fetch-package-metadata: use unpipe
for 0.8 compatibility instead of trying to kill the streams by hand Fixes #8695 PR-URL: https://github.com/npm/npm/pull/8718
-rw-r--r--lib/fetch-package-metadata.js14
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/fetch-package-metadata.js b/lib/fetch-package-metadata.js
index 6c41bfdf0..5c349c688 100644
--- a/lib/fetch-package-metadata.js
+++ b/lib/fetch-package-metadata.js
@@ -13,6 +13,7 @@ var iferr = require('iferr')
var rimraf = require('rimraf')
var clone = require('lodash.clonedeep')
var validate = require('aproba')
+var unpipe = require('unpipe')
var npm = require('./npm.js')
var mapToRegistry = require('./utils/map-to-registry.js')
@@ -256,9 +257,9 @@ function untarStream (tarball, cb) {
validate('SF', arguments)
cb = once(cb)
- var tounpipe = []
var stream
var file = stream = fs.createReadStream(tarball)
+ var tounpipe = [file]
file.on('error', function (er) {
er = new Error('Error extracting ' + tarball + ' archive: ' + er.message)
er.code = 'EREADFILE'
@@ -287,7 +288,7 @@ function untarStream (tarball, cb) {
er.code = 'EGUNZIP'
cb(er)
})
- tounpipe.push([stream, gunzip])
+ tounpipe.push(gunzip)
stream = gunzip
doUntar()
}
@@ -299,18 +300,19 @@ function untarStream (tarball, cb) {
er.code = 'EUNTAR'
cb(er)
})
- tounpipe.push([stream, untar])
+ tounpipe.push(untar)
stream = untar
addClose()
}
function addClose () {
stream.close = function () {
- tounpipe.forEach(function (streams) {
- streams[0].unpipe(streams[1])
+ tounpipe.forEach(function (stream) {
+ unpipe(stream)
})
- file.close()
+ if (file.close) file.close()
+ if (file.destroy) file.destroy()
}
}
}