UNPKG

563 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
9function stars (args, cb) {
10 var name = args.length === 1 ? args[0] : npm.config.get("username")
11 registry.stars(name, showstars)
12
13 function showstars (er, data) {
14 if (er) {
15 return cb(er)
16 }
17
18 if (data.rows.length === 0) {
19 log.warn('stars', 'user has not starred any packages.')
20 } else {
21 data.rows.forEach(function(a) {
22 console.log(a.value)
23 })
24 }
25 cb()
26 }
27}