]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/update.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / lib / update.js
1 /*
2 for each pkg in prefix that isn't a git repo
3   look for a new version of pkg that satisfies dep
4   if so, install it.
5   if not, then update it
6 */
7
8 module.exports = update
9
10 update.usage = "npm update [pkg]"
11
12 var npm = require("./npm.js")
13   , asyncMap = require("slide").asyncMap
14   , log = require("npmlog")
15
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")
20
21 update.completion = npm.commands.outdated.completion
22
23 function update (args, cb) {
24   npm.commands.outdated(args, true, function (er, outdated) {
25     if (er) return cb(er)
26
27     var wanted = outdated.filter(function (ww) {
28       var dep = ww[1]
29       var current = ww[2]
30       var wanted = ww[3]
31       var latest = ww[4]
32       if (current === wanted && wanted !== latest) {
33         log.verbose(
34           'outdated',
35           'not updating', dep,
36           "because it's currently at the maximum version that matches its specified semver range"
37         )
38       }
39       return current !== wanted
40     })
41     if (wanted.length === 0) return cb()
42
43     log.info('outdated', 'updating', wanted)
44     asyncMap(wanted, function (ww, cb) {
45       // [[ dir, dep, has, want, req ]]
46       var where = ww[0]
47         , dep = ww[1]
48         , want = ww[3]
49         , what = dep + "@" + want
50         , req = ww[5]
51         , url = require('url')
52
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)
56     }, cb)
57   })
58 }