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

star.js « lib - github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: bf68582ca1654d6c546df0fb76c134e90f62586c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36

module.exports = star

var url = require("url")
  , npm = require("./npm.js")
  , registry = npm.registry
  , log = require("npmlog")
  , asyncMap = require("slide").asyncMap

star.usage = "npm star <package> [pkg, pkg, ...]\n"
           + "npm unstar <package> [pkg, pkg, ...]"

star.completion = function (opts, cb) {
  var uri = url.resolve(npm.config.get("registry"), "/-/short")
  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) {
    var uri = url.resolve(npm.config.get("registry"), pkg)
    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)
}