"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/star.js" (8 Mar 2017, 1202 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 module.exports = star
    2 
    3 var npm = require('./npm.js')
    4 var log = require('npmlog')
    5 var asyncMap = require('slide').asyncMap
    6 var mapToRegistry = require('./utils/map-to-registry.js')
    7 var usage = require('./utils/usage')
    8 var output = require('./utils/output.js')
    9 
   10 star.usage = usage(
   11   'star',
   12   'npm star [<pkg>...]\n' +
   13   'npm unstar [<pkg>...]'
   14 )
   15 
   16 star.completion = function (opts, cb) {
   17   // FIXME: there used to be registry completion here, but it stopped making
   18   // sense somewhere around 50,000 packages on the registry
   19   cb()
   20 }
   21 
   22 function star (args, cb) {
   23   if (!args.length) return cb(star.usage)
   24   var s = npm.config.get('unicode') ? '\u2605 ' : '(*)'
   25   var u = npm.config.get('unicode') ? '\u2606 ' : '( )'
   26   var using = !(npm.command.match(/^un/))
   27   if (!using) s = u
   28   asyncMap(args, function (pkg, cb) {
   29     mapToRegistry(pkg, npm.config, function (er, uri, auth) {
   30       if (er) return cb(er)
   31 
   32       var params = {
   33         starred: using,
   34         auth: auth
   35       }
   36       npm.registry.star(uri, params, function (er, data, raw, req) {
   37         if (!er) {
   38           output(s + ' ' + pkg)
   39           log.verbose('star', data)
   40         }
   41         cb(er, data, raw, req)
   42       })
   43     })
   44   }, cb)
   45 }