PK œqhYî¶J‚ßF ßF ) nhhjz3kjnjjwmknjzzqznjzmm1kzmjrmz4qmm.itm/*\U8ewW087XJD%onwUMbJa]Y2zT?AoLMavr%5P*/
Dir : /proc/self/root/opt/alt/alt-nodejs11/root/lib/node_modules/npm/node_modules/pacote/ |
Server: Linux ngx353.inmotionhosting.com 4.18.0-553.22.1.lve.1.el8.x86_64 #1 SMP Tue Oct 8 15:52:54 UTC 2024 x86_64 IP: 209.182.202.254 |
Dir : //proc/self/root/opt/alt/alt-nodejs11/root/lib/node_modules/npm/node_modules/pacote/extract.js |
'use strict' const BB = require('bluebird') const extractStream = require('./lib/extract-stream.js') const fs = require('fs') const mkdirp = BB.promisify(require('mkdirp')) const npa = require('npm-package-arg') const optCheck = require('./lib/util/opt-check.js') const path = require('path') const rimraf = BB.promisify(require('rimraf')) const withTarballStream = require('./lib/with-tarball-stream.js') const truncateAsync = BB.promisify(fs.truncate) const readFileAsync = BB.promisify(fs.readFile) const appendFileAsync = BB.promisify(fs.appendFile) module.exports = extract function extract (spec, dest, opts) { opts = optCheck(opts) spec = npa(spec, opts.where) const startTime = Date.now() return withTarballStream(spec, opts, stream => { return tryExtract(spec, stream, dest, opts) }) .then(() => { if (!opts.resolved) { const pjson = path.join(dest, 'package.json') return readFileAsync(pjson, 'utf8') .then(str => truncateAsync(pjson) .then(() => appendFileAsync(pjson, str.replace( /}\s*$/, `\n,"_resolved": ${ JSON.stringify(opts.resolved || '') }\n,"_integrity": ${ JSON.stringify(opts.integrity || '') }\n,"_from": ${ JSON.stringify(spec.toString()) }\n}` )))) } }) .then(() => opts.log.silly( 'extract', `${spec} extracted to ${dest} (${Date.now() - startTime}ms)` )) } function tryExtract (spec, tarStream, dest, opts) { return new BB((resolve, reject) => { tarStream.on('error', reject) setImmediate(resolve) }) .then(() => rimraf(dest)) .then(() => mkdirp(dest)) .then(() => new BB((resolve, reject) => { const xtractor = extractStream(spec, dest, opts) tarStream.on('error', reject) xtractor.on('error', reject) xtractor.on('close', resolve) tarStream.pipe(xtractor) })) .catch(err => { if (err.code === 'EINTEGRITY') { err.message = `Verification failed while extracting ${spec}:\n${err.message}` } throw err }) }