"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm-registry-client/lib/deprecate.js" (7 Feb 2017, 1304 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 = deprecate
    2 
    3 var assert = require('assert')
    4 var semver = require('semver')
    5 
    6 function deprecate (uri, params, cb) {
    7   assert(typeof uri === 'string', 'must pass registry URI to deprecate')
    8   assert(params && typeof params === 'object', 'must pass params to deprecate')
    9   assert(typeof cb === 'function', 'must pass callback to deprecate')
   10 
   11   assert(typeof params.version === 'string', 'must pass version to deprecate')
   12   assert(typeof params.message === 'string', 'must pass message to deprecate')
   13   assert(
   14     params.auth && typeof params.auth === 'object',
   15     'must pass auth to deprecate'
   16   )
   17 
   18   var version = params.version
   19   var message = params.message
   20   var auth = params.auth
   21 
   22   if (semver.validRange(version) === null) {
   23     return cb(new Error('invalid version range: ' + version))
   24   }
   25 
   26   this.get(uri + '?write=true', { auth: auth }, function (er, data) {
   27     if (er) return cb(er)
   28     // filter all the versions that match
   29     Object.keys(data.versions).filter(function (v) {
   30       return semver.satisfies(v, version)
   31     }).forEach(function (v) {
   32       data.versions[v].deprecated = message
   33     })
   34     // now update the doc on the registry
   35     var options = {
   36       method: 'PUT',
   37       body: data,
   38       auth: auth
   39     }
   40     this.request(uri, options, cb)
   41   }.bind(this))
   42 }