1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 | module.exports = update
|
9 |
|
10 | update.usage = "npm update [pkg]"
|
11 |
|
12 | var npm = require("./npm.js")
|
13 | , lifecycle = require("./utils/lifecycle.js")
|
14 | , asyncMap = require("slide").asyncMap
|
15 | , log = require("npmlog")
|
16 |
|
17 |
|
18 |
|
19 | , install = require("./install.js")
|
20 | , build = require("./build.js")
|
21 |
|
22 | update.completion = npm.commands.outdated.completion
|
23 |
|
24 | function update (args, cb) {
|
25 | npm.commands.outdated(args, true, function (er, outdated) {
|
26 | log.info("outdated", "updating", outdated)
|
27 | if (er) return cb(er)
|
28 |
|
29 | asyncMap(outdated, function (ww, cb) {
|
30 |
|
31 | var where = ww[0]
|
32 | , dep = ww[1]
|
33 | , want = ww[3]
|
34 | , what = dep + "@" + want
|
35 | , req = ww[5]
|
36 | , url = require('url')
|
37 |
|
38 |
|
39 | if (url.parse(req).protocol) what = req
|
40 | npm.commands.install(where, what, cb)
|
41 | }, cb)
|
42 | })
|
43 | }
|