403Webshell
Server IP : 66.29.132.122  /  Your IP : 52.14.216.87
Web Server : LiteSpeed
System : Linux business142.web-hosting.com 4.18.0-553.lve.el8.x86_64 #1 SMP Mon May 27 15:27:34 UTC 2024 x86_64
User : admazpex ( 531)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /lib/node_modules/npm/lib/utils/completion/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/node_modules/npm/lib/utils/completion/installed-shallow.js
module.exports = installedShallow

var npm = require('../../npm.js')
var fs = require('graceful-fs')
var path = require('path')
var readJson = require('read-package-json')
var asyncMap = require('slide').asyncMap

function installedShallow (opts, filter, cb) {
  if (typeof cb !== 'function') {
    cb = filter
    filter = null
  }
  var conf = opts.conf
  var args = conf.argv.remain
  if (args.length > 3) return cb()
  var local
  var global
  var localDir = npm.dir
  var globalDir = npm.globalDir
  if (npm.config.get('global')) {
    local = []
    next()
  } else {
    fs.readdir(localDir, function (er, pkgs) {
      local = (pkgs || []).filter(function (p) {
        return p.charAt(0) !== '.'
      })
      next()
    })
  }

  fs.readdir(globalDir, function (er, pkgs) {
    global = (pkgs || []).filter(function (p) {
      return p.charAt(0) !== '.'
    })
    next()
  })
  function next () {
    if (!local || !global) return
    filterInstalled(local, global, filter, cb)
  }
}

function filterInstalled (local, global, filter, cb) {
  var fl
  var fg

  if (!filter) {
    fl = local
    fg = global
    return next()
  }

  asyncMap(local, function (p, cb) {
    readJson(path.join(npm.dir, p, 'package.json'), function (er, d) {
      if (!d || !filter(d)) return cb(null, [])
      return cb(null, d.name)
    })
  }, function (er, local) {
    fl = local || []
    next()
  })

  var globalDir = npm.globalDir
  asyncMap(global, function (p, cb) {
    readJson(path.join(globalDir, p, 'package.json'), function (er, d) {
      if (!d || !filter(d)) return cb(null, [])
      return cb(null, d.name)
    })
  }, function (er, global) {
    fg = global || []
    next()
  })

  function next () {
    if (!fg || !fl) return
    if (!npm.config.get('global')) {
      fg = fg.map(function (g) {
        return [g, '-g']
      })
    }
    console.error('filtered', fl, fg)
    return cb(null, fl.concat(fg))
  }
}

Youez - 2016 - github.com/yon3zu
LinuXploit