This repository has been archived by the owner. It is now read-only.

Discover newer versions of dependencies than package.json allows #1638

Closed
wants to merge 4 commits into
base: master
from

Cleaned up the code so there is no need of specifying a callback when…

… invoking npm.commands.view; added a call to runNpmView when dealing with error while reading the filesystem
  • Loading branch information...
lazywithclass committed Oct 13, 2011
commit 14c6c8551f0dc0317acdcc666220464ba960d568
View
@@ -89,7 +89,7 @@ function outdated_ (args, dir, parentHas, cb) {
fs.readdir(path.resolve(dir, "node_modules"), function (er, pkgs) {
if (er) {
has = Object.create(parentHas)
//TODO what to do here?
runNpmView(has)
return next()
}
asyncMap(pkgs, function (pkg, cb) {
@@ -99,38 +99,30 @@ function outdated_ (args, dir, parentHas, cb) {
})
}, function (er, pvs) {
if (er) return cb(er)
has = Object.create(parentHas)
discoverNew(has, function (er, result) {
for (var key in result) {
var newest = key.split("@")
var currentVersion = has[newest[0]]
var newestVersion = newest[1]
if (semver.gt(newestVersion, currentVersion)) {
cb(null, [[dir, newest[0], currentVersion, currentVersion, newestVersion]])
}
}
})
has = Object.create(parentHas)
runNpmView(has)
pvs.forEach(function (pv) {
has[pv[0]] = pv[1]
})
next()
})
})
function dump (obj) {
var out = '';
for (var i in obj) {
out += i + ": " + obj[i] + "\n";
}
console.log("*** dumping***\n")
}
function discoverNew (has, cb) {
function runNpmView (has) {
var keys = []
for (var key in has) {
keys.push(key)
}
npm.commands.view(["mkdirp"], true, cb)
npm.commands.view(["mkdirp"], true, function (er, result) {
for (var key in result) {
var newest = key.split("@")
var currentVersion = has[newest[0]]
var newestVersion = newest[1]
if (semver.gt(newestVersion, currentVersion)) {
cb(null, [[dir, newest[0], currentVersion, currentVersion, newestVersion]])
}
}
})
}
function next () {
ProTip! Use n and p to navigate between commits in a pull request.