"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/team.js" (8 Mar 2017, 1439 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 var mapToRegistry = require('./utils/map-to-registry.js')
    2 var npm = require('./npm')
    3 var output = require('./utils/output.js')
    4 
    5 module.exports = team
    6 
    7 team.subcommands = ['create', 'destroy', 'add', 'rm', 'ls', 'edit']
    8 
    9 team.usage =
   10   'npm team create <scope:team>\n' +
   11   'npm team destroy <scope:team>\n' +
   12   'npm team add <scope:team> <user>\n' +
   13   'npm team rm <scope:team> <user>\n' +
   14   'npm team ls <scope>|<scope:team>\n' +
   15   'npm team edit <scope:team>'
   16 
   17 team.completion = function (opts, cb) {
   18   var argv = opts.conf.argv.remain
   19   if (argv.length === 2) {
   20     return cb(null, team.subcommands)
   21   }
   22   switch (argv[2]) {
   23     case 'ls':
   24     case 'create':
   25     case 'destroy':
   26     case 'add':
   27     case 'rm':
   28     case 'edit':
   29       return cb(null, [])
   30     default:
   31       return cb(new Error(argv[2] + ' not recognized'))
   32   }
   33 }
   34 
   35 function team (args, cb) {
   36   // Entities are in the format <scope>:<team>
   37   var cmd = args.shift()
   38   var entity = (args.shift() || '').split(':')
   39   return mapToRegistry('/', npm.config, function (err, uri, auth) {
   40     if (err) { return cb(err) }
   41     try {
   42       return npm.registry.team(cmd, uri, {
   43         auth: auth,
   44         scope: entity[0],
   45         team: entity[1],
   46         user: args.shift()
   47       }, function (err, data) {
   48         !err && data && output(JSON.stringify(data, undefined, 2))
   49         cb(err, data)
   50       })
   51     } catch (e) {
   52       cb(e.message + '\n\nUsage:\n' + team.usage)
   53     }
   54   })
   55 }