"Fossies" - the Fresh Open Source Software Archive

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