UNPKG

816 BJavaScriptView Raw
1module.exports = stars
2
3stars.usage = "npm stars [username]"
4
5var npm = require("./npm.js")
6 , log = require("npmlog")
7 , mapToRegistry = require("./utils/map-to-registry.js")
8
9function stars (args, cb) {
10 npm.commands.whoami([], true, function (er, username) {
11 var name = args.length === 1 ? args[0] : username
12 mapToRegistry("", npm.config, function (er, uri, auth) {
13 if (er) return cb(er)
14
15 var params = {
16 username : name,
17 auth : auth
18 }
19 npm.registry.stars(uri, params, showstars)
20 })
21 })
22
23 function showstars (er, data) {
24 if (er) return cb(er)
25
26 if (data.rows.length === 0) {
27 log.warn("stars", "user has not starred any packages.")
28 } else {
29 data.rows.forEach(function(a) {
30 console.log(a.value)
31 })
32 }
33 cb()
34 }
35}