"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/npm/lib/utils/completion/installed-deep.js" (8 Mar 2017, 1142 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 = installedDeep
    2 
    3 var npm = require('../../npm.js')
    4 var readInstalled = require('read-installed')
    5 
    6 function installedDeep (opts, cb) {
    7   var local
    8   var global
    9   var depth = npm.config.get('depth')
   10   var opt = { depth: depth, dev: true }
   11 
   12   if (npm.config.get('global')) {
   13     local = []
   14     next()
   15   } else {
   16     readInstalled(npm.prefix, opt, function (er, data) {
   17       local = getNames(data || {})
   18       next()
   19     })
   20   }
   21 
   22   readInstalled(npm.config.get('prefix'), opt, function (er, data) {
   23     global = getNames(data || {})
   24     next()
   25   })
   26 
   27   function getNames_ (d, n) {
   28     if (d.realName && n) {
   29       if (n[d.realName]) return n
   30       n[d.realName] = true
   31     }
   32     if (!n) n = {}
   33     Object.keys(d.dependencies || {}).forEach(function (dep) {
   34       getNames_(d.dependencies[dep], n)
   35     })
   36     return n
   37   }
   38   function getNames (d) {
   39     return Object.keys(getNames_(d))
   40   }
   41 
   42   function next () {
   43     if (!local || !global) return
   44     if (!npm.config.get('global')) {
   45       global = global.map(function (g) {
   46         return [g, '-g']
   47       })
   48     }
   49     var names = local.concat(global)
   50     return cb(null, names)
   51   }
   52 }