"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/update.js" (8 Mar 2017, 1799 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 module.exports = update
    2 
    3 var url = require('url')
    4 var log = require('npmlog')
    5 var chain = require('slide').chain
    6 var npm = require('./npm.js')
    7 var Installer = require('./install.js').Installer
    8 var usage = require('./utils/usage')
    9 
   10 update.usage = usage(
   11   'update',
   12   'npm update [-g] [<pkg>...]'
   13 )
   14 
   15 update.completion = npm.commands.outdated.completion
   16 
   17 function update (args, cb) {
   18   var dryrun = false
   19   if (npm.config.get('dry-run')) dryrun = true
   20 
   21   npm.commands.outdated(args, true, function (er, rawOutdated) {
   22     if (er) return cb(er)
   23     var outdated = rawOutdated.map(function (ww) {
   24       return {
   25         dep: ww[0],
   26         depname: ww[1],
   27         current: ww[2],
   28         wanted: ww[3],
   29         latest: ww[4],
   30         req: ww[5],
   31         what: ww[1] + '@' + ww[3]
   32       }
   33     })
   34 
   35     var wanted = outdated.filter(function (ww) {
   36       if (ww.current === ww.wanted && ww.wanted !== ww.latest) {
   37         log.verbose(
   38           'outdated',
   39           'not updating', ww.depname,
   40           "because it's currently at the maximum version that matches its specified semver range"
   41         )
   42       }
   43       return ww.current !== ww.wanted && ww.latest !== 'linked'
   44     })
   45     if (wanted.length === 0) return cb()
   46 
   47     log.info('outdated', 'updating', wanted)
   48     var toInstall = {}
   49     wanted.forEach(function (ww) {
   50       // use the initial installation method (repo, tar, git) for updating
   51       if (url.parse(ww.req).protocol) ww.what = ww.req
   52 
   53       var where = ww.dep.parent && ww.dep.parent.path || ww.dep.path
   54       if (toInstall[where]) {
   55         toInstall[where].push(ww.what)
   56       } else {
   57         toInstall[where] = [ww.what]
   58       }
   59     })
   60     chain(Object.keys(toInstall).map(function (where) {
   61       return [new Installer(where, dryrun, toInstall[where]), 'run']
   62     }), cb)
   63   })
   64 }