"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/deprecate.js" (11 Apr 2017, 1429 Bytes) of package /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 var npm = require('./npm.js')
    2 var mapToRegistry = require('./utils/map-to-registry.js')
    3 var npa = require('npm-package-arg')
    4 
    5 module.exports = deprecate
    6 
    7 deprecate.usage = 'npm deprecate <pkg>[@<version>] <message>'
    8 
    9 deprecate.completion = function (opts, cb) {
   10   // first, get a list of remote packages this user owns.
   11   // once we have a user account, then don't complete anything.
   12   if (opts.conf.argv.remain.length > 2) return cb()
   13   // get the list of packages by user
   14   var path = '/-/by-user/'
   15   mapToRegistry(path, npm.config, function (er, uri, c) {
   16     if (er) return cb(er)
   17 
   18     if (!(c && c.username)) return cb()
   19 
   20     var params = {
   21       timeout: 60000,
   22       auth: c
   23     }
   24     npm.registry.get(uri + c.username, params, function (er, list) {
   25       if (er) return cb()
   26       console.error(list)
   27       return cb(null, list[c.username])
   28     })
   29   })
   30 }
   31 
   32 function deprecate (args, cb) {
   33   var pkg = args[0]
   34   var msg = args[1]
   35   if (msg === undefined) return cb('Usage: ' + deprecate.usage)
   36 
   37   // fetch the data and make sure it exists.
   38   var p = npa(pkg)
   39 
   40   // npa makes the default spec "latest", but for deprecation
   41   // "*" is the appropriate default.
   42   if (p.rawSpec === '') p.spec = '*'
   43 
   44   mapToRegistry(p.name, npm.config, function (er, uri, auth) {
   45     if (er) return cb(er)
   46 
   47     var params = {
   48       version: p.spec,
   49       message: msg,
   50       auth: auth
   51     }
   52     npm.registry.deprecate(uri, params, cb)
   53   })
   54 }