Browse files

adds a feature to allow users to view starred packages

  • Loading branch information...
1 parent 79738d7 commit 11efb737fc019d090f23d6db384a9f053d4d7de8 @0x00A 0x00A committed with isaacs Feb 15, 2013
Showing with 50 additions and 0 deletions.
  1. +22 −0 doc/cli/stars.md
  2. +1 −0 lib/npm.js
  3. +27 −0 lib/stars.js
View
22 doc/cli/stars.md
@@ -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
1 lib/npm.js
@@ -127,6 +127,7 @@ var commandCache = {}
, "publish"
, "star"
+ , "stars"
, "tag"
, "adduser"
, "unpublish"
View
27 lib/stars.js
@@ -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()
+ }
+}

0 comments on commit 11efb73

Please sign in to comment.