node/deps/npm/lib/stars.js

36 lines
816 B
JavaScript
Raw Normal View History

2013-02-16 02:49:16 +08:00
module.exports = stars
stars.usage = "npm stars [username]"
2014-09-25 05:41:07 +08:00
var npm = require("./npm.js")
2013-02-16 02:49:16 +08:00
, log = require("npmlog")
2014-09-25 05:41:07 +08:00
, mapToRegistry = require("./utils/map-to-registry.js")
2013-02-16 02:49:16 +08:00
function stars (args, cb) {
2014-09-25 05:41:07 +08:00
npm.commands.whoami([], true, function (er, username) {
var name = args.length === 1 ? args[0] : username
mapToRegistry("", npm.config, function (er, uri, auth) {
2014-09-25 05:41:07 +08:00
if (er) return cb(er)
var params = {
username : name,
auth : auth
}
npm.registry.stars(uri, params, showstars)
2014-09-25 05:41:07 +08:00
})
})
2013-02-16 02:49:16 +08:00
function showstars (er, data) {
2014-09-25 05:41:07 +08:00
if (er) return cb(er)
2013-02-16 02:49:16 +08:00
if (data.rows.length === 0) {
2014-09-25 05:41:07 +08:00
log.warn("stars", "user has not starred any packages.")
2013-02-16 02:49:16 +08:00
} else {
data.rows.forEach(function(a) {
console.log(a.value)
})
}
cb()
}
}