"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/stars.js" (11 Apr 2017, 1123 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 = stars
    2 
    3 stars.usage = 'npm stars [<user>]'
    4 
    5 var npm = require('./npm.js')
    6 var log = require('npmlog')
    7 var mapToRegistry = require('./utils/map-to-registry.js')
    8 var output = require('./utils/output.js')
    9 
   10 function stars (args, cb) {
   11   npm.commands.whoami([], true, function (er, username) {
   12     var name = args.length === 1 ? args[0] : username
   13 
   14     if (er) {
   15       if (er.code === 'ENEEDAUTH' && !name) {
   16         var needAuth = new Error("'npm stars' on your own user account requires auth")
   17         needAuth.code = 'ENEEDAUTH'
   18         return cb(needAuth)
   19       }
   20 
   21       if (er.code !== 'ENEEDAUTH') return cb(er)
   22     }
   23 
   24     mapToRegistry('', npm.config, function (er, uri, auth) {
   25       if (er) return cb(er)
   26 
   27       var params = {
   28         username: name,
   29         auth: auth
   30       }
   31       npm.registry.stars(uri, params, showstars)
   32     })
   33   })
   34 
   35   function showstars (er, data) {
   36     if (er) return cb(er)
   37 
   38     if (data.rows.length === 0) {
   39       log.warn('stars', 'user has not starred any packages.')
   40     } else {
   41       data.rows.forEach(function (a) {
   42         output(a.value)
   43       })
   44     }
   45     cb()
   46   }
   47 }