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:
authorisaacs <i@izs.me>2011-10-15 05:05:14 +0400
committerisaacs <i@izs.me>2011-10-15 05:07:14 +0400
commit0f7ffc2023e6d551ba0821bc5155cf37268d383f (patch)
treebbf7bd257ebbe945d66dadd50abd897b5dfbb17d
parent904744577157b0dbf1f158bed69e0de49a088017 (diff)
Fix #1555 Queue tar operations for windows
*Really* need to get a js tar implementation in there asap.
-rw-r--r--lib/utils/tar.js52
1 files changed, 45 insertions, 7 deletions
diff --git a/lib/utils/tar.js b/lib/utils/tar.js
index b60b3a427..37cd6bcc6 100644
--- a/lib/utils/tar.js
+++ b/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