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-19 03:53:57 +0300
committerRebecca Turner <me@re-becca.org>2015-06-26 03:27:30 +0300
commitbc46ca9e1c01ad6fcd55e55907dd8ea2991a3ff6 (patch)
treed1423b182850cf758c7227a14fc93b667850c5bc
parent8fb8b4a047e74ae06248e424874aa704c871b249 (diff)
install: Make shrinkwrap extraction work in 0.8
-rw-r--r--lib/fetch-package-metadata.js17
1 files changed, 10 insertions, 7 deletions
diff --git a/lib/fetch-package-metadata.js b/lib/fetch-package-metadata.js
index 6c159a489..98ad9bb3f 100644
--- a/lib/fetch-package-metadata.js
+++ b/lib/fetch-package-metadata.js
@@ -253,6 +253,11 @@ function hasTarHeader (c) {
c[264] === 0x00))
}
+function dispose (stream) {
+ if (stream.destroy) return stream.destroy()
+ if (stream.close) return stream.close()
+}
+
function untarStream (tarball, cb) {
validate('SF', arguments)
cb = once(cb)
@@ -273,7 +278,7 @@ function untarStream (tarball, cb) {
doUntar()
}
else {
- file.close()
+ dispose(file)
var er = new Error('Non-gzip/tarball ' + tarball)
er.code = 'ENOTTARBALL'
return cb(er)
@@ -290,7 +295,7 @@ function untarStream (tarball, cb) {
er.code = 'EGUNZIP'
cb(er)
})
- tounpipe.push([stream, gunzip])
+ tounpipe.push(gunzip)
stream = gunzip
doUntar()
}
@@ -302,18 +307,16 @@ 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(dispose)
- file.close()
+ dispose(file)
}
}
}