Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Remove a lot of unnecessary code

  • Loading branch information...
commit 5aebba1a92510c054724babb0076f65aa12e4fea 1 parent ff1bc34
@isaacs isaacs authored
Showing with 6 additions and 48 deletions.
  1. +6 −48 lib/utils/tar.js
View
54 lib/utils/tar.js
@@ -27,40 +27,20 @@ exports.pack = pack
exports.unpack = unpack
exports.makeList = makeList
-var packQueue = []
- , packing = false
-
-function pack (targetTarball, folder, pkg, dfc, cb_) {
- if (typeof cb_ !== "function") cb_ = dfc, dfc = true
+function pack (targetTarball, folder, pkg, dfc, cb) {
+ if (typeof cb !== "function") cb = dfc, dfc = true
folder = path.resolve(process.cwd(), folder)
if (typeof pkg === "function") {
- cb_ = pkg, pkg = null
+ cb = pkg, pkg = null
return readJson(path.resolve(folder, "package.json"), function (er, pkg) {
- if (er) return log.er(cb_, "Couldn't find package.json in "+folder)(er)
- pack(targetTarball, folder, pkg, dfc, cb_)
+ if (er) return log.er(cb, "Couldn't find package.json in "+folder)(er)
+ pack(targetTarball, folder, pkg, dfc, cb)
})
}
log.verbose(folder+" "+targetTarball, "pack")
var parent = path.dirname(folder)
, addFolder = path.basename(folder)
- cb_ = log.er(cb_, "Failed creating the tarball.")
-
-
- // XXX Rip out all this crap and use a tar get gets along with windows.
- if (packing && process.platform === "win32") {
- packQueue.push([targetTarball, folder, pkg, dfc, cb_])
- return
- }
-
- packing = true
- function cb (er, data) {
- packing = false
- var next = packQueue.shift()
- if (next) return pack.apply(null, next)
- cb_(er, data)
- }
-
var confEx = npm.config.get("ignore")
log.silly(folder, "makeList")
makeList(folder, pkg, dfc, function (er, files, cleanup) {
@@ -91,12 +71,10 @@ function packFiles (targetTarball, parent, files, pkg, cb) {
parent = path.resolve(parent, p)
log.verbose(targetTarball, "tarball")
- log.silly(files, "files")
log.verbose(parent, "parent")
fstream.Reader({ type: "Directory"
, path: parent
, filter: function () {
- log.silly(this.path, "filtering")
return -1 !== files.indexOf(this.path)
// || (this.type === "Directory" &&
// this.basename !== ".git")
@@ -105,7 +83,6 @@ function packFiles (targetTarball, parent, files, pkg, cb) {
})
.on("error", log.er(cb, "error reading "+parent))
.on("entry", function E (entry) {
- log.silly(entry.path, "add entry")
entry.on("entry", E)
})
.pipe(tar.Pack({}))
@@ -130,24 +107,7 @@ function unpack (tarball, unpackTarget, dMode, fMode, uid, gid, cb) {
})
}
-// XXX Rip all this crap out and use a tar that gets along with windows.
-var unpackQueue = []
- , unpacking = false
-
-function unpack_ ( tarball, unpackTarget, dMode, fMode, uid, gid, cb_ ) {
- if (unpacking && process.platform === "win32") {
- unpackQueue.push([tarball, unpackTarget, dMode, fMode, uid, gid, cb_])
- return
- }
-
- unpacking = true
- function cb (er, data) {
- unpacking = false
- var next = unpackQueue.shift()
- if (next) return unpack_.apply(null, next)
- cb_(er, data)
- }
-
+function unpack_ ( tarball, unpackTarget, dMode, fMode, uid, gid, cb ) {
// If the desired target is /path/to/foo,
// then unpack into /path/to/.foo.npm/{something}
// rename that to /path/to/foo, and delete /path/to/.foo.npm
@@ -224,7 +184,6 @@ function gunzTarPerm (tarball, tmp, dMode, fMode, uid, gid, cb) {
files = files.filter(function (f) {
return f && f.indexOf("\0") === -1
})
- log.silly("skip chmod for windows")
cb(er, files && path.resolve(tmp, files[0]))
})
}
@@ -565,7 +524,6 @@ function makeList_ (dir, pkg, exList, dfc, cb) {
})
}, function (er, files, c) {
if (c) cleanup = (cleanup || []).concat(c)
- log.silly([dir, files], "found in makeList_")
if (files.length > 0) files.push(dir)
return cb(er, files, cleanup)
})
Please sign in to comment.
Something went wrong with that request. Please try again.