"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm-registry-client/lib/dist-tags/add.js" (11 Apr 2017, 1152 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 module.exports = add
    2 
    3 var assert = require('assert')
    4 var url = require('url')
    5 
    6 var npa = require('npm-package-arg')
    7 
    8 function add (uri, params, cb) {
    9   assert(typeof uri === 'string', 'must pass registry URI to distTags.add')
   10   assert(
   11     params && typeof params === 'object',
   12     'must pass params to distTags.add'
   13   )
   14   assert(typeof cb === 'function', 'muss pass callback to distTags.add')
   15 
   16   assert(
   17     typeof params.package === 'string',
   18     'must pass package name to distTags.add'
   19   )
   20   assert(
   21     typeof params.distTag === 'string',
   22     'must pass package distTag name to distTags.add'
   23   )
   24   assert(
   25     typeof params.version === 'string',
   26     'must pass version to be mapped to distTag to distTags.add'
   27   )
   28   assert(
   29     params.auth && typeof params.auth === 'object',
   30     'must pass auth to distTags.add'
   31   )
   32 
   33   var p = npa(params.package)
   34   var pkg = p.scope ? params.package.replace('/', '%2f') : params.package
   35   var rest = '-/package/' + pkg + '/dist-tags/' + params.distTag
   36 
   37   var options = {
   38     method: 'PUT',
   39     body: JSON.stringify(params.version),
   40     auth: params.auth
   41   }
   42   this.request(url.resolve(uri, rest), options, cb)
   43 }