mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.1 KiB
42 lines
1.1 KiB
|
|
module.exports = star
|
|
|
|
var npm = require("./npm.js")
|
|
, registry = npm.registry
|
|
, log = require("npmlog")
|
|
, asyncMap = require("slide").asyncMap
|
|
, mapToRegistry = require("./utils/map-to-registry.js")
|
|
|
|
star.usage = "npm star <package> [pkg, pkg, ...]\n"
|
|
+ "npm unstar <package> [pkg, pkg, ...]"
|
|
|
|
star.completion = function (opts, cb) {
|
|
mapToRegistry("-/short", npm.config, function (er, uri) {
|
|
if (er) return cb(er)
|
|
|
|
registry.get(uri, { timeout : 60000 }, function (er, list) {
|
|
return cb(null, list || [])
|
|
})
|
|
})
|
|
}
|
|
|
|
function star (args, cb) {
|
|
if (!args.length) return cb(star.usage)
|
|
var s = npm.config.get("unicode") ? "\u2605 " : "(*)"
|
|
, u = npm.config.get("unicode") ? "\u2606 " : "( )"
|
|
, using = !(npm.command.match(/^un/))
|
|
if (!using) s = u
|
|
asyncMap(args, function (pkg, cb) {
|
|
mapToRegistry(pkg, npm.config, function (er, uri) {
|
|
if (er) return cb(er)
|
|
|
|
registry.star(uri, using, function (er, data, raw, req) {
|
|
if (!er) {
|
|
console.log(s + " "+pkg)
|
|
log.verbose("star", data)
|
|
}
|
|
cb(er, data, raw, req)
|
|
})
|
|
})
|
|
}, cb)
|
|
}
|
|
|