Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doc/cli/stars.md22
-rw-r--r--lib/npm.js1
-rw-r--r--lib/stars.js27
3 files changed, 50 insertions, 0 deletions
diff --git a/doc/cli/stars.md b/doc/cli/stars.md
new file mode 100644
index 000000000..7c28f5b2a
--- /dev/null
+++ b/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)
diff --git a/lib/npm.js b/lib/npm.js
index a8122762f..2028b34f0 100644
--- a/lib/npm.js
+++ b/lib/npm.js
@@ -127,6 +127,7 @@ var commandCache = {}
, "publish"
, "star"
+ , "stars"
, "tag"
, "adduser"
, "unpublish"
diff --git a/lib/stars.js b/lib/stars.js
new file mode 100644
index 000000000..74841f2de
--- /dev/null
+++ b/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()
+ }
+}