]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/stars.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / lib / stars.js
1 module.exports = stars
2
3 stars.usage = "npm stars [username]"
4
5 var npm = require("./npm.js")
6   , log = require("npmlog")
7   , mapToRegistry = require("./utils/map-to-registry.js")
8
9 function stars (args, cb) {
10   npm.commands.whoami([], true, function (er, username) {
11     var name = args.length === 1 ? args[0] : username
12
13     if (er) {
14       if (er.code === 'ENEEDAUTH' && !name) {
15         var needAuth = new Error("'npm stars' on your own user account requires auth")
16         needAuth.code = 'ENEEDAUTH'
17         return cb(needAuth)
18       }
19
20       if (er.code !== 'ENEEDAUTH') return cb(er)
21     }
22
23     mapToRegistry("", npm.config, function (er, uri, auth) {
24       if (er) return cb(er)
25
26       var params = {
27         username : name,
28         auth     : auth
29       }
30       npm.registry.stars(uri, params, showstars)
31     })
32   })
33
34   function showstars (er, data) {
35     if (er) return cb(er)
36
37     if (data.rows.length === 0) {
38       log.warn("stars", "user has not starred any packages.")
39     } else {
40       data.rows.forEach(function(a) {
41         console.log(a.value)
42       })
43     }
44     cb()
45   }
46 }