2 for each pkg in prefix that isn't a git repo
3 look for a new version of pkg that satisfies dep
8 module.exports = update
10 update.usage = "npm update [pkg]"
12 var npm = require("./npm.js")
13 , asyncMap = require("slide").asyncMap
14 , log = require("npmlog")
16 // load these, just so that we know that they'll be available, in case
17 // npm itself is getting overwritten.
18 , install = require("./install.js")
19 , build = require("./build.js")
21 update.completion = npm.commands.outdated.completion
23 function update (args, cb) {
24 npm.commands.outdated(args, true, function (er, outdated) {
27 var wanted = outdated.filter(function (ww) {
32 if (current === wanted && wanted !== latest) {
36 "because it's currently at the maximum version that matches its specified semver range"
39 return current !== wanted
41 if (wanted.length === 0) return cb()
43 log.info('outdated', 'updating', wanted)
44 asyncMap(wanted, function (ww, cb) {
45 // [[ dir, dep, has, want, req ]]
49 , what = dep + "@" + want
51 , url = require('url')
53 // use the initial installation method (repo, tar, git) for updating
54 if (url.parse(req).protocol) what = req
55 npm.commands.install(where, what, cb)