diff options
author | isaacs <i@izs.me> | 2012-04-17 17:14:25 -0700 |
---|---|---|
committer | isaacs <i@izs.me> | 2012-04-18 09:36:40 -0700 |
commit | c8bbd13ea8d692f9f28f69cbb7ff321d7b998126 (patch) | |
tree | fb7074902b3332d2179c1e461277ada29016b531 /deps/npm/lib | |
parent | d8b33dc14787213a47a0f10f37137ec476d92952 (diff) | |
download | node-new-c8bbd13ea8d692f9f28f69cbb7ff321d7b998126.tar.gz |
Upgrade npm to 1.1.17
Diffstat (limited to 'deps/npm/lib')
-rw-r--r-- | deps/npm/lib/bugs.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/docs.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/init.js | 5 | ||||
-rw-r--r-- | deps/npm/lib/install.js | 20 | ||||
-rw-r--r-- | deps/npm/lib/npm.js | 19 | ||||
-rw-r--r-- | deps/npm/lib/utils/config-defs.js | 9 | ||||
-rw-r--r-- | deps/npm/lib/utils/fetch.js | 1 | ||||
-rw-r--r-- | deps/npm/lib/utils/npm-registry-client/request.js | 2 | ||||
-rw-r--r-- | deps/npm/lib/utils/read-installed.js | 3 |
9 files changed, 53 insertions, 10 deletions
diff --git a/deps/npm/lib/bugs.js b/deps/npm/lib/bugs.js index a3a017cc02..7982746cfb 100644 --- a/deps/npm/lib/bugs.js +++ b/deps/npm/lib/bugs.js @@ -28,7 +28,7 @@ function bugs (args, cb) { } if (repo) { if (Array.isArray(repo)) repo = repo.shift() - if (repo.url) repo = repo.url + if (repo.hasOwnProperty("url")) repo = repo.url log.verbose(repo, "repository") if (repo && repo.match(/^(https?:\/\/|git(:\/\/|@))github.com/)) { return open(repo.replace(/^git(@|:\/\/)/, "http://") diff --git a/deps/npm/lib/docs.js b/deps/npm/lib/docs.js index de9f71c654..8af4c1bb66 100644 --- a/deps/npm/lib/docs.js +++ b/deps/npm/lib/docs.js @@ -25,7 +25,7 @@ function docs (args, cb) { if (homepage) return open(homepage, cb) if (repo) { if (Array.isArray(repo)) repo = repo.shift() - if (repo.url) repo = repo.url + if (repo.hasOwnProperty("url")) repo = repo.url log.verbose(repo, "repository") if (repo) { return open(repo.replace(/^git(@|:\/\/)/, 'http://') diff --git a/deps/npm/lib/init.js b/deps/npm/lib/init.js index 1c64d97607..7cd7da8e27 100644 --- a/deps/npm/lib/init.js +++ b/deps/npm/lib/init.js @@ -99,7 +99,10 @@ function init_ (data, folder, cb) { , function (er, r) { if (er) return cb(er) if (r !== "none") { - data.repository = (data.repository || {}).url = r + data.repository = (data.repository || {}) + data.repository.url = r + } else { + delete data.repository } cb() } diff --git a/deps/npm/lib/install.js b/deps/npm/lib/install.js index 4da66d3383..5873ca968e 100644 --- a/deps/npm/lib/install.js +++ b/deps/npm/lib/install.js @@ -211,7 +211,7 @@ function readDependencies (context, where, opts, cb) { rv[key] = data[key] }) rv.dependencies = {} - Object.keys(newwrap.dependencies).forEach(function (key) { + Object.keys(newwrap.dependencies || {}).forEach(function (key) { var w = newwrap.dependencies[key] rv.dependencies[key] = w.from || w.version }) @@ -225,7 +225,10 @@ function readDependencies (context, where, opts, cb) { // as dependencies to a package.json file. // This is experimental. function save (where, installed, tree, pretty, cb) { - if (!npm.config.get("save") || npm.config.get("global")) { + if (!npm.config.get("save") && + !npm.config.get("save-dev") && + !npm.config.get("save-optional") || + npm.config.get("global")) { return cb(null, installed, tree, pretty) } @@ -257,13 +260,18 @@ function save (where, installed, tree, pretty, cb) { } catch (ex) { er = ex } - if (er) return cb(null, installed, tree, pretty) + if (er) { + return cb(null, installed, tree, pretty) - var deps = npm.config.get("dev") ? "devDependencies" : "dependencies" - deps = data[deps] = data[deps] || {} + } + + var deps = npm.config.get("save-optional") ? "optionalDependencies" + : npm.config.get("save-dev") ? "devDependencies" + : "dependencies" + data[deps] = data[deps] || {} Object.keys(things).forEach(function (t) { - deps[t] = things[t] + data[deps][t] = things[t] }) data = JSON.stringify(data, null, 2) + "\n" fs.writeFile(saveTarget, data, function (er) { diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js index 456948a29b..2db21e34de 100644 --- a/deps/npm/lib/npm.js +++ b/deps/npm/lib/npm.js @@ -26,10 +26,27 @@ var EventEmitter = require("events").EventEmitter , semver = require("semver") , findPrefix = require("./utils/find-prefix.js") , getUid = require("uid-number") - , mkdir = require("mkdirp") + , mkdirp = require("mkdirp") , slide = require("slide") , chain = slide.chain +// /usr/local is often a read-only fs, which is not +// well handled by node or mkdirp. Just double-check +// in the case of errors when making the prefix dirs. +function mkdir (p, cb) { + mkdirp(p, function (er, made) { + // it could be that we couldn't create it, because it + // already exists, and is on a read-only fs. + if (er) { + return fs.stat(p, function (er2, st) { + if (er2 || !st.isDirectory()) return cb(er) + return cb(null, made) + }) + } + return cb(er, made) + }) +} + npm.commands = {} npm.ELIFECYCLE = {} npm.E404 = {} diff --git a/deps/npm/lib/utils/config-defs.js b/deps/npm/lib/utils/config-defs.js index 39df42f915..18b47ecdb7 100644 --- a/deps/npm/lib/utils/config-defs.js +++ b/deps/npm/lib/utils/config-defs.js @@ -9,6 +9,7 @@ var path = require("path") , os = require("os") , nopt = require("nopt") , log = require("./log.js") + , npm = require("../npm.js") function Octal () {} function validateOctal (data, k, val) { @@ -183,10 +184,13 @@ Object.defineProperty(exports, "defaults", {get: function () { , proxy : process.env.HTTP_PROXY || process.env.http_proxy || null , "https-proxy" : process.env.HTTPS_PROXY || process.env.https_proxy || process.env.HTTP_PROXY || process.env.http_proxy || null + , "user-agent" : "npm/" + npm.version + " node/" + process.version , "rebuild-bundle" : true , registry : "http" + (httpsOk ? "s" : "") + "://registry.npmjs.org/" , rollback : true , save : false + , "save-dev" : false + , "save-optional" : false , searchopts: "" , searchexclude: null , searchsort: "name" @@ -239,6 +243,7 @@ exports.types = , globalignorefile: path , group : [Number, String] , "https-proxy" : [null, url] + , "user-agent" : String , ignore : String , "init.version" : [null, semver] , "init.author.name" : String @@ -266,6 +271,8 @@ exports.types = , registry : [null, url] , rollback : Boolean , save : Boolean + , "save-dev" : Boolean + , "save-optional" : Boolean , searchopts : String , searchexclude: [null, String] , searchsort: [ "name", "-name" @@ -321,6 +328,8 @@ exports.shorthands = , porcelain : ["--parseable"] , g : ["--global"] , S : ["--save"] + , D : ["--save-dev"] + , O : ["--save-optional"] , y : ["--yes"] , n : ["--no-yes"] } diff --git a/deps/npm/lib/utils/fetch.js b/deps/npm/lib/utils/fetch.js index 0ece53cabf..bc1c095cdf 100644 --- a/deps/npm/lib/utils/fetch.js +++ b/deps/npm/lib/utils/fetch.js @@ -59,6 +59,7 @@ function makeRequest (remote, fstr, headers) { , proxy: proxy , strictSSL: npm.config.get("strict-ssl") , ca: remote.host === regHost ? npm.config.get("ca") : undefined + , headers: { "user-agent": npm.config.get("user-agent") } , onResponse: onResponse }).pipe(fstr) function onResponse (er, res) { if (er) return fstr.emit("error", er) diff --git a/deps/npm/lib/utils/npm-registry-client/request.js b/deps/npm/lib/utils/npm-registry-client/request.js index 5213c7966b..d5122629dd 100644 --- a/deps/npm/lib/utils/npm-registry-client/request.js +++ b/deps/npm/lib/utils/npm-registry-client/request.js @@ -94,6 +94,8 @@ function makeRequest (method, remote, where, what, etag, nofollow, cb) { headers.accept = "application/json" + headers["user-agent"] = npm.config.get("user-agent") + opts.proxy = npm.config.get( remote.protocol === "https:" ? "https-proxy" : "proxy" ) diff --git a/deps/npm/lib/utils/read-installed.js b/deps/npm/lib/utils/read-installed.js index 60cbea15c5..ff220943d6 100644 --- a/deps/npm/lib/utils/read-installed.js +++ b/deps/npm/lib/utils/read-installed.js @@ -94,6 +94,7 @@ var npm = require("../npm.js") , semver = require("semver") , readJson = require("./read-json.js") , log = require("./log.js") + , url = require("url") module.exports = readInstalled @@ -254,6 +255,8 @@ function findUnmet (obj) { continue } if ( typeof deps[d] === "string" + // url deps presumed innocent. + && !url.parse(deps[d]).protocol && !semver.satisfies(found.version, deps[d])) { // the bad thing will happen log.warn(obj.path + " requires "+d+"@'"+deps[d] |