UNPKG

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