"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/docs.js" (8 Mar 2017, 1058 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 = docs
    2 
    3 var npm = require('./npm.js')
    4 var opener = require('opener')
    5 var log = require('npmlog')
    6 var fetchPackageMetadata = require('./fetch-package-metadata.js')
    7 var usage = require('./utils/usage')
    8 
    9 docs.usage = usage(
   10   'docs',
   11   'npm docs <pkgname>' +
   12   '\nnpm docs .'
   13 )
   14 docs.completion = function (opts, cb) {
   15   // FIXME: there used to be registry completion here, but it stopped making
   16   // sense somewhere around 50,000 packages on the registry
   17   cb()
   18 }
   19 
   20 function docs (args, cb) {
   21   if (!args || !args.length) args = ['.']
   22   var pending = args.length
   23   log.silly('docs', args)
   24   args.forEach(function (proj) {
   25     getDoc(proj, function (err) {
   26       if (err) {
   27         return cb(err)
   28       }
   29       --pending || cb()
   30     })
   31   })
   32 }
   33 
   34 function getDoc (project, cb) {
   35   log.silly('getDoc', project)
   36   fetchPackageMetadata(project, '.', function (er, d) {
   37     if (er) return cb(er)
   38     var url = d.homepage
   39     if (!url) url = 'https://www.npmjs.org/package/' + d.name
   40     return opener(url, {command: npm.config.get('browser')}, cb)
   41   })
   42 }