adds a feature to allow users to view starred packages

This commit is contained in:
Paolo Fragomeni
2013-02-15 00:26:42 -05:00
committed by isaacs
parent 79738d7f90
commit 11efb737fc
3 changed files with 50 additions and 0 deletions

22
doc/cli/stars.md Normal file
View File

@@ -0,0 +1,22 @@
npm-stars(1) -- View packages marked as favorites
=================================================
## SYNOPSIS
npm stars
npm stars [username]
## DESCRIPTION
If you have starred a lot of neat things and want to find them again
quickly this command lets you do just that.
You may also want to see your friend's favorite packages, in this case
you will most certainly enjoy this command.
## SEE ALSO
* npm-star(1)
* npm-view(1)
* npm-whoami(1)
* npm-adduser(1)

View File

@@ -127,6 +127,7 @@ var commandCache = {}
, "publish"
, "star"
, "stars"
, "tag"
, "adduser"
, "unpublish"

27
lib/stars.js Normal file
View File

@@ -0,0 +1,27 @@
module.exports = stars
stars.usage = "npm stars [username]"
var npm = require("./npm.js")
, registry = npm.registry
, log = require("npmlog")
function stars (args, cb) {
var name = args.length === 1 ? args[0] : npm.config.get("username")
registry.stars(name, showstars)
function showstars (er, data) {
if (er) {
return cb(er)
}
if (data.rows.length === 0) {
log.warn('stars', 'user has not starred any packages.')
} else {
data.rows.forEach(function(a) {
console.log(a.value)
})
}
cb()
}
}