diff options
author | isaacs <i@izs.me> | 2013-03-20 17:49:57 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-03-20 17:49:57 -0700 |
commit | 3dd7938c03389371ce1d142a8558a98b450ca2ee (patch) | |
tree | be7bf56caefeaec9b6a872fc903963b8fba6e48b /deps/npm/lib | |
parent | 855caa82aaef5c6e6dd244b5d9df314994cb23eb (diff) | |
download | node-3dd7938c03389371ce1d142a8558a98b450ca2ee.tar.gz |
npm: upgrade to 1.2.15
Diffstat (limited to 'deps/npm/lib')
-rw-r--r-- | deps/npm/lib/cache.js | 20 | ||||
-rw-r--r-- | deps/npm/lib/install.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/rebuild.js | 30 | ||||
-rw-r--r-- | deps/npm/lib/utils/exec.js | 3 | ||||
-rw-r--r-- | deps/npm/lib/utils/fetch.js | 47 |
5 files changed, 48 insertions, 54 deletions
diff --git a/deps/npm/lib/cache.js b/deps/npm/lib/cache.js index 7cb92af14..4f8fbc4fe 100644 --- a/deps/npm/lib/cache.js +++ b/deps/npm/lib/cache.js @@ -573,8 +573,8 @@ function addNamed (name, x, data, cb_) { }) } -function addNameTag (name, tag, data, cb) { - if (typeof cb !== "function") cb = data, data = null +function addNameTag (name, tag, data, cb_) { + if (typeof cb_ !== "function") cb_ = data, data = null log.info("addNameTag", [name, tag]) var explicit = true if (!tag) { @@ -582,6 +582,15 @@ function addNameTag (name, tag, data, cb) { tag = npm.config.get("tag") } + function cb(er, data) { + // might be username/project + // in that case, try it as a github url. + if (er && tag.split("/").length === 2) { + return maybeGithub(tag, name, er, cb_) + } + return cb_(er, data) + } + registry.get(name, function (er, data, json, response) { if (er) return cb(er) engineFilter(data) @@ -595,13 +604,6 @@ function addNameTag (name, tag, data, cb) { } er = installTargetsError(tag, data) - - // might be username/project - // in that case, try it as a github url. - if (tag.split("/").length === 2) { - return maybeGithub(tag, name, er, cb) - } - return cb(er) }) } diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js index 9f63c7463..4db8d58ef 100644 --- a/deps/npm/lib/install.js +++ b/deps/npm/lib/install.js @@ -679,7 +679,7 @@ function targetResolver (where, context, deps) { if (data && !data._from) data._from = what - return cb(er, data) + return cb(er, data || []) }) } } diff --git a/deps/npm/lib/rebuild.js b/deps/npm/lib/rebuild.js index 16451fbbb..0c97cf85d 100644 --- a/deps/npm/lib/rebuild.js +++ b/deps/npm/lib/rebuild.js @@ -29,32 +29,12 @@ function rebuild (args, cb) { } function cleanBuild (folders, set, cb) { - // https://github.com/isaacs/npm/issues/1872 - // If there's a wscript, try 'node-waf clean' - // But don't die on either of those if they fail. - // Just a best-effort kind of deal. - asyncMap(folders, function (f, cb) { - fs.readdir(f, function (er, files) { - // everything should be a dir. - if (er) return cb(er) - if (files.indexOf("wscript") !== -1) { - exec("node-waf", ["clean"], null, false, f, thenBuild) - } else thenBuild() - }) - function thenBuild (er) { - // ignore error, just continue - // it could be that it's not configured yet or whatever. - cb() - } - }, function (er) { + npm.commands.build(folders, function (er) { if (er) return cb(er) - npm.commands.build(folders, function (er) { - if (er) return cb(er) - console.log(folders.map(function (f) { - return set[f] + " " + f - }).join("\n")) - cb() - }) + console.log(folders.map(function (f) { + return set[f] + " " + f + }).join("\n")) + cb() }) } diff --git a/deps/npm/lib/utils/exec.js b/deps/npm/lib/utils/exec.js index 70f0a13d9..360367cbf 100644 --- a/deps/npm/lib/utils/exec.js +++ b/deps/npm/lib/utils/exec.js @@ -10,6 +10,7 @@ var log = require("npmlog") , isRoot = process.getuid && myUID === 0 , constants = require("constants") , uidNumber = require("uid-number") + , once = require("once") function exec (cmd, args, env, takeOver, cwd, uid, gid, cb) { if (typeof cb !== "function") cb = gid, gid = null @@ -45,6 +46,8 @@ function exec (cmd, args, env, takeOver, cwd, uid, gid, cb) { var stdout = "" , stderr = "" , cp = spawn(cmd, args, env, takeOver, cwd, uid, gid) + cb = once(cb) + cp.on("error", cb) cp.stdout && cp.stdout.on("data", function (chunk) { if (chunk) stdout += chunk }) diff --git a/deps/npm/lib/utils/fetch.js b/deps/npm/lib/utils/fetch.js index b98852066..526b836a2 100644 --- a/deps/npm/lib/utils/fetch.js +++ b/deps/npm/lib/utils/fetch.js @@ -11,11 +11,13 @@ var request = require("request") , mkdir = require("mkdirp") , chownr = require("chownr") , regHost + , once = require("once") module.exports = fetch function fetch (remote, local, headers, cb) { if (typeof cb !== "function") cb = headers, headers = {} + cb = once(cb) log.verbose("fetch", "to=", local) mkdir(path.dirname(local), function (er, made) { if (er) return cb(er) @@ -26,30 +28,36 @@ function fetch (remote, local, headers, cb) { function fetch_ (remote, local, headers, cb) { var fstr = fs.createWriteStream(local, { mode : npm.modes.file }) var response = null - var calledback = false + fstr.on("error", function (er) { - fs.close(fstr.fd, function () {}) - if (calledback) return - calledback = true - cb(fstr._ERROR = er) + cb(er) + fstr.close() }) - fstr.on("open", function () { - var req = makeRequest(remote, fstr, headers) - req.on("response", function (res) { - log.http(res.statusCode, remote) - response = res - }) + + var req = makeRequest(remote, fstr, headers) + req.on("response", function (res) { + log.http(res.statusCode, remote) + response = res + response.resume() + // Work around bug in node v0.10.0 where the CryptoStream + // gets stuck and never starts reading again. + if (process.version === "v0.10.0") { + response.resume = function (orig) { return function() { + var ret = orig.apply(response, arguments) + if (response.socket.encrypted) + response.socket.encrypted.read(0) + return ret + }}(response.resume) + } }) + fstr.on("close", function () { - if (calledback) return - calledback = true + var er if (response && response.statusCode && response.statusCode >= 400) { - var er = new Error(response.statusCode + " " - + require("http").STATUS_CODES[response.statusCode]) - cb(fstr._ERROR = er, response) - } else { - cb(null, response) + er = new Error(response.statusCode + " " + + require("http").STATUS_CODES[response.statusCode]) } + cb(er, response) }) } @@ -73,6 +81,7 @@ function makeRequest (remote, fstr, headers) { var opts = { url: remote , proxy: proxy , strictSSL: npm.config.get("strict-ssl") + , rejectUnauthorized: npm.config.get("strict-ssl") , ca: remote.host === regHost ? npm.config.get("ca") : undefined , headers: { "user-agent": npm.config.get("user-agent") }} var req = request(opts) @@ -80,5 +89,5 @@ function makeRequest (remote, fstr, headers) { fstr.emit("error", er) }) req.pipe(fstr) - return req; + return req } |