mirror of
https://github.com/zhigang1992/npm.git
synced 2026-04-29 04:25:30 +08:00
adds a feature to allow users to view starred packages
This commit is contained in:
22
doc/cli/stars.md
Normal file
22
doc/cli/stars.md
Normal 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)
|
||||
@@ -127,6 +127,7 @@ var commandCache = {}
|
||||
|
||||
, "publish"
|
||||
, "star"
|
||||
, "stars"
|
||||
, "tag"
|
||||
, "adduser"
|
||||
, "unpublish"
|
||||
|
||||
27
lib/stars.js
Normal file
27
lib/stars.js
Normal 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()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user