Skip to content
Browse files

Fix #1555 Queue tar operations for windows

*Really* need to get a js tar implementation in there asap.
  • Loading branch information...
1 parent 9047445 commit 0f7ffc2023e6d551ba0821bc5155cf37268d383f @isaacs isaacs committed
Showing with 45 additions and 7 deletions.
  1. +45 −7 lib/utils/tar.js
View
52 lib/utils/tar.js
@@ -24,22 +24,41 @@ 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.")
+ 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) process.nextTick(function () {
+ pack.apply(null, next)
+ })
+ cb_(er, data)
+ }
var confEx = npm.config.get("ignore")
makeList(folder, pkg, dfc, function (er, files, cleanup) {
@@ -113,7 +132,26 @@ function unpack (tarball, unpackTarget, dMode, fMode, uid, gid, cb) {
})
}
-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) process.nextTick(function () {
+ unpack_.apply(null, next)
+ })
+ cb_(er, data)
+ }
+
// 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

0 comments on commit 0f7ffc2

Please sign in to comment.
Something went wrong with that request. Please try again.