From 5abdef790c5b9ea5d8424289bf026b3e422ccf7e Mon Sep 17 00:00:00 2001 From: isaacs Date: Fri, 16 Aug 2013 08:19:31 -0700 Subject: npm: Upgrade to 1.3.8 --- deps/npm/lib/cache.js | 10 ++-------- deps/npm/lib/npm.js | 1 + deps/npm/lib/outdated.js | 18 +++++++++++++----- deps/npm/lib/repo.js | 29 +++++++++++++++++++++++++++++ deps/npm/lib/search.js | 3 +-- 5 files changed, 46 insertions(+), 15 deletions(-) create mode 100644 deps/npm/lib/repo.js (limited to 'deps/npm/lib') diff --git a/deps/npm/lib/cache.js b/deps/npm/lib/cache.js index 3739968f6..a8bd6b388 100644 --- a/deps/npm/lib/cache.js +++ b/deps/npm/lib/cache.js @@ -1203,17 +1203,11 @@ function lockFileName (u) { return path.resolve(npm.config.get("cache"), h + "-" + c + ".lock") } -var madeCache = false var myLocks = {} function lock (u, cb) { // the cache dir needs to exist already for this. - if (madeCache) then() - else mkdir(npm.config.get("cache"), function (er) { + getCacheStat(function (er, cs) { if (er) return cb(er) - madeCache = true - then() - }) - function then () { var opts = { stale: npm.config.get("cache-lock-stale") , retries: npm.config.get("cache-lock-retries") , wait: npm.config.get("cache-lock-wait") } @@ -1223,7 +1217,7 @@ function lock (u, cb) { if (!er) myLocks[lf] = true cb(er) }) - } + }) } function unlock (u, cb) { diff --git a/deps/npm/lib/npm.js b/deps/npm/lib/npm.js index ea9759265..8b8ee95b0 100644 --- a/deps/npm/lib/npm.js +++ b/deps/npm/lib/npm.js @@ -146,6 +146,7 @@ var commandCache = {} , "edit" , "explore" , "docs" + , "repo" , "bugs" , "faq" , "root" diff --git a/deps/npm/lib/outdated.js b/deps/npm/lib/outdated.js index b205922ef..b21e10d06 100644 --- a/deps/npm/lib/outdated.js +++ b/deps/npm/lib/outdated.js @@ -93,13 +93,16 @@ function outdated_ (args, dir, parentHas, cb) { var jsonFile = path.resolve(dir, "node_modules", pkg, "package.json") readJson(jsonFile, function (er, d) { if (er && er.code !== "ENOENT" && er.code !== "ENOTDIR") return cb(er) - cb(null, er ? [] : [[d.name, d.version]]) + cb(null, er ? [] : [[d.name, d.version, d._from]]) }) }, function (er, pvs) { if (er) return cb(er) has = Object.create(parentHas) pvs.forEach(function (pv) { - has[pv[0]] = pv[1] + has[pv[0]] = { + version: pv[1], + from: pv[2] + } }) next() @@ -129,6 +132,9 @@ function shouldUpdate (args, dir, dep, has, req, cb) { // if that's what we already have, or if it's not on the args list, // then dive into it. Otherwise, cb() with the data. + // { version: , from: } + var curr = has[dep] + function skip () { outdated_( args , path.resolve(dir, "node_modules", dep) @@ -137,7 +143,7 @@ function shouldUpdate (args, dir, dep, has, req, cb) { } function doIt (shouldHave) { - cb(null, [[ dir, dep, has[dep], shouldHave, req ]]) + cb(null, [[ dir, dep, curr.version, shouldHave, req ]]) } if (args.length && args.indexOf(dep) === -1) { @@ -147,7 +153,9 @@ function shouldUpdate (args, dir, dep, has, req, cb) { // so, we can conceivably update this. find out if we need to. cache.add(dep, req, function (er, d) { // if this fails, then it means we can't update this thing. - // it's probably a thing that isn't published. - return (er || d.version === has[dep]) ? skip() : doIt(d.version) + // it's probably a thing that isn't published. otherwise + // check that the origin hasn't changed (#1727) and that + // there is no newer version available + return (er || (d._from === curr.from && d.version === has[dep])) ? skip() : doIt(d.version) }) } diff --git a/deps/npm/lib/repo.js b/deps/npm/lib/repo.js new file mode 100644 index 000000000..19066c822 --- /dev/null +++ b/deps/npm/lib/repo.js @@ -0,0 +1,29 @@ + +module.exports = repo + +repo.usage = "npm repo " + +repo.completion = function (opts, cb) { + if (opts.conf.argv.remain.length > 2) return cb() + registry.get("/-/short", 60000, function (er, list) { + return cb(null, list || []) + }) +} + +var npm = require("./npm.js") + , registry = npm.registry + , log = require("npmlog") + , opener = require("opener") + , github = require('github-url-from-git') + +function repo (args, cb) { + if (!args.length) return cb(repo.usage) + var n = args[0].split("@").shift() + registry.get(n + "/latest", 3600, function (er, d) { + if (er) return cb(er) + var r = d.repository; + if (!r) return cb(new Error('no repository')); + var url = github(r.url); + opener(url, { command: npm.config.get("browser") }, cb) + }) +} diff --git a/deps/npm/lib/search.js b/deps/npm/lib/search.js index c758f869a..fdc1c8b07 100644 --- a/deps/npm/lib/search.js +++ b/deps/npm/lib/search.js @@ -85,7 +85,7 @@ function stripData (data) { }) , url: !Object.keys(data.versions || {}).length ? data.url : null , keywords: data.keywords || [] - , version: Object.keys(data.versions)[0] || [] + , version: Object.keys(data.versions || {})[0] || [] , time: data.time && data.time.modified && (new Date(data.time.modified).toISOString() @@ -133,7 +133,6 @@ function prettify (data, args) { var tty = require("tty") , stdout = process.stdout , cols = !tty.isatty(stdout.fd) ? Infinity - : stdout._handle ? stdout._handle.getWindowSize()[0] : process.stdout.getWindowSize()[0] cols = (cols == 0) ? Infinity : cols } catch (ex) { cols = Infinity } -- cgit v1.2.1