Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib/node_mod.../npm/lib
File: install.js
'use strict'
[0] Fix | Delete
/* eslint-disable camelcase */
[1] Fix | Delete
/* eslint-disable standard/no-callback-literal */
[2] Fix | Delete
// npm install <pkg> <pkg> <pkg>
[3] Fix | Delete
//
[4] Fix | Delete
// See doc/cli/npm-install.md for more description
[5] Fix | Delete
//
[6] Fix | Delete
// Managing contexts...
[7] Fix | Delete
// there's a lot of state associated with an "install" operation, including
[8] Fix | Delete
// packages that are already installed, parent packages, current shrinkwrap, and
[9] Fix | Delete
// so on. We maintain this state in a "context" object that gets passed around.
[10] Fix | Delete
// every time we dive into a deeper node_modules folder, the "family" list that
[11] Fix | Delete
// gets passed along uses the previous "family" list as its __proto__. Any
[12] Fix | Delete
// "resolved precise dependency" things that aren't already on this object get
[13] Fix | Delete
// added, and then that's passed to the next generation of installation.
[14] Fix | Delete
[15] Fix | Delete
module.exports = install
[16] Fix | Delete
module.exports.Installer = Installer
[17] Fix | Delete
[18] Fix | Delete
var usage = require('./utils/usage')
[19] Fix | Delete
[20] Fix | Delete
install.usage = usage(
[21] Fix | Delete
'install',
[22] Fix | Delete
'\nnpm install (with no args, in package dir)' +
[23] Fix | Delete
'\nnpm install [<@scope>/]<pkg>' +
[24] Fix | Delete
'\nnpm install [<@scope>/]<pkg>@<tag>' +
[25] Fix | Delete
'\nnpm install [<@scope>/]<pkg>@<version>' +
[26] Fix | Delete
'\nnpm install [<@scope>/]<pkg>@<version range>' +
[27] Fix | Delete
'\nnpm install <alias>@npm:<name>' +
[28] Fix | Delete
'\nnpm install <folder>' +
[29] Fix | Delete
'\nnpm install <tarball file>' +
[30] Fix | Delete
'\nnpm install <tarball url>' +
[31] Fix | Delete
'\nnpm install <git:// url>' +
[32] Fix | Delete
'\nnpm install <github username>/<github project>',
[33] Fix | Delete
'[--save-prod|--save-dev|--save-optional] [--save-exact] [--no-save]'
[34] Fix | Delete
)
[35] Fix | Delete
[36] Fix | Delete
install.completion = function (opts, cb) {
[37] Fix | Delete
validate('OF', arguments)
[38] Fix | Delete
// install can complete to a folder with a package.json, or any package.
[39] Fix | Delete
// if it has a slash, then it's gotta be a folder
[40] Fix | Delete
// if it starts with https?://, then just give up, because it's a url
[41] Fix | Delete
if (/^https?:\/\//.test(opts.partialWord)) {
[42] Fix | Delete
// do not complete to URLs
[43] Fix | Delete
return cb(null, [])
[44] Fix | Delete
}
[45] Fix | Delete
[46] Fix | Delete
if (/\//.test(opts.partialWord)) {
[47] Fix | Delete
// Complete fully to folder if there is exactly one match and it
[48] Fix | Delete
// is a folder containing a package.json file. If that is not the
[49] Fix | Delete
// case we return 0 matches, which will trigger the default bash
[50] Fix | Delete
// complete.
[51] Fix | Delete
var lastSlashIdx = opts.partialWord.lastIndexOf('/')
[52] Fix | Delete
var partialName = opts.partialWord.slice(lastSlashIdx + 1)
[53] Fix | Delete
var partialPath = opts.partialWord.slice(0, lastSlashIdx)
[54] Fix | Delete
if (partialPath === '') partialPath = '/'
[55] Fix | Delete
[56] Fix | Delete
var annotatePackageDirMatch = function (sibling, cb) {
[57] Fix | Delete
var fullPath = path.join(partialPath, sibling)
[58] Fix | Delete
if (sibling.slice(0, partialName.length) !== partialName) {
[59] Fix | Delete
return cb(null, null) // not name match
[60] Fix | Delete
}
[61] Fix | Delete
fs.readdir(fullPath, function (err, contents) {
[62] Fix | Delete
if (err) return cb(null, { isPackage: false })
[63] Fix | Delete
[64] Fix | Delete
cb(
[65] Fix | Delete
null,
[66] Fix | Delete
{
[67] Fix | Delete
fullPath: fullPath,
[68] Fix | Delete
isPackage: contents.indexOf('package.json') !== -1
[69] Fix | Delete
}
[70] Fix | Delete
)
[71] Fix | Delete
})
[72] Fix | Delete
}
[73] Fix | Delete
[74] Fix | Delete
return fs.readdir(partialPath, function (err, siblings) {
[75] Fix | Delete
if (err) return cb(null, []) // invalid dir: no matching
[76] Fix | Delete
[77] Fix | Delete
asyncMap(siblings, annotatePackageDirMatch, function (err, matches) {
[78] Fix | Delete
if (err) return cb(err)
[79] Fix | Delete
[80] Fix | Delete
var cleaned = matches.filter(function (x) { return x !== null })
[81] Fix | Delete
if (cleaned.length !== 1) return cb(null, [])
[82] Fix | Delete
if (!cleaned[0].isPackage) return cb(null, [])
[83] Fix | Delete
[84] Fix | Delete
// Success - only one match and it is a package dir
[85] Fix | Delete
return cb(null, [cleaned[0].fullPath])
[86] Fix | Delete
})
[87] Fix | Delete
})
[88] Fix | Delete
}
[89] Fix | Delete
[90] Fix | Delete
// FIXME: there used to be registry completion here, but it stopped making
[91] Fix | Delete
// sense somewhere around 50,000 packages on the registry
[92] Fix | Delete
cb()
[93] Fix | Delete
}
[94] Fix | Delete
[95] Fix | Delete
// system packages
[96] Fix | Delete
var fs = require('fs')
[97] Fix | Delete
var path = require('path')
[98] Fix | Delete
[99] Fix | Delete
// dependencies
[100] Fix | Delete
var log = require('npmlog')
[101] Fix | Delete
var readPackageTree = require('read-package-tree')
[102] Fix | Delete
var readPackageJson = require('read-package-json')
[103] Fix | Delete
var chain = require('slide').chain
[104] Fix | Delete
var asyncMap = require('slide').asyncMap
[105] Fix | Delete
var archy = require('archy')
[106] Fix | Delete
var mkdirp = require('gentle-fs').mkdir
[107] Fix | Delete
var rimraf = require('rimraf')
[108] Fix | Delete
var iferr = require('iferr')
[109] Fix | Delete
var validate = require('aproba')
[110] Fix | Delete
var uniq = require('lodash.uniq')
[111] Fix | Delete
var Bluebird = require('bluebird')
[112] Fix | Delete
[113] Fix | Delete
// npm internal utils
[114] Fix | Delete
var npm = require('./npm.js')
[115] Fix | Delete
var locker = require('./utils/locker.js')
[116] Fix | Delete
var lock = locker.lock
[117] Fix | Delete
var unlock = locker.unlock
[118] Fix | Delete
var parseJSON = require('./utils/parse-json.js')
[119] Fix | Delete
var output = require('./utils/output.js')
[120] Fix | Delete
var saveMetrics = require('./utils/metrics.js').save
[121] Fix | Delete
[122] Fix | Delete
// install specific libraries
[123] Fix | Delete
var copyTree = require('./install/copy-tree.js')
[124] Fix | Delete
var readShrinkwrap = require('./install/read-shrinkwrap.js')
[125] Fix | Delete
var computeMetadata = require('./install/deps.js').computeMetadata
[126] Fix | Delete
var prefetchDeps = require('./install/deps.js').prefetchDeps
[127] Fix | Delete
var loadDeps = require('./install/deps.js').loadDeps
[128] Fix | Delete
var loadDevDeps = require('./install/deps.js').loadDevDeps
[129] Fix | Delete
var getAllMetadata = require('./install/deps.js').getAllMetadata
[130] Fix | Delete
var loadRequestedDeps = require('./install/deps.js').loadRequestedDeps
[131] Fix | Delete
var loadExtraneous = require('./install/deps.js').loadExtraneous
[132] Fix | Delete
var diffTrees = require('./install/diff-trees.js')
[133] Fix | Delete
var checkPermissions = require('./install/check-permissions.js')
[134] Fix | Delete
var decomposeActions = require('./install/decompose-actions.js')
[135] Fix | Delete
var validateTree = require('./install/validate-tree.js')
[136] Fix | Delete
var validateArgs = require('./install/validate-args.js')
[137] Fix | Delete
var saveRequested = require('./install/save.js').saveRequested
[138] Fix | Delete
var saveShrinkwrap = require('./install/save.js').saveShrinkwrap
[139] Fix | Delete
var audit = require('./install/audit.js')
[140] Fix | Delete
var {
[141] Fix | Delete
getPrintFundingReport,
[142] Fix | Delete
getPrintFundingReportJSON
[143] Fix | Delete
} = require('./install/fund.js')
[144] Fix | Delete
var getSaveType = require('./install/save.js').getSaveType
[145] Fix | Delete
var doSerialActions = require('./install/actions.js').doSerial
[146] Fix | Delete
var doReverseSerialActions = require('./install/actions.js').doReverseSerial
[147] Fix | Delete
var doParallelActions = require('./install/actions.js').doParallel
[148] Fix | Delete
var doOneAction = require('./install/actions.js').doOne
[149] Fix | Delete
var removeObsoleteDep = require('./install/deps.js').removeObsoleteDep
[150] Fix | Delete
var removeExtraneous = require('./install/deps.js').removeExtraneous
[151] Fix | Delete
var computeVersionSpec = require('./install/deps.js').computeVersionSpec
[152] Fix | Delete
var packageId = require('./utils/package-id.js')
[153] Fix | Delete
var moduleName = require('./utils/module-name.js')
[154] Fix | Delete
var errorMessage = require('./utils/error-message.js')
[155] Fix | Delete
var isExtraneous = require('./install/is-extraneous.js')
[156] Fix | Delete
[157] Fix | Delete
function unlockCB (lockPath, name, cb) {
[158] Fix | Delete
validate('SSF', arguments)
[159] Fix | Delete
return function (installEr) {
[160] Fix | Delete
var args = arguments
[161] Fix | Delete
try {
[162] Fix | Delete
unlock(lockPath, name, reportErrorAndReturn)
[163] Fix | Delete
} catch (unlockEx) {
[164] Fix | Delete
process.nextTick(function () {
[165] Fix | Delete
reportErrorAndReturn(unlockEx)
[166] Fix | Delete
})
[167] Fix | Delete
}
[168] Fix | Delete
function reportErrorAndReturn (unlockEr) {
[169] Fix | Delete
if (installEr) {
[170] Fix | Delete
if (unlockEr && unlockEr.code !== 'ENOTLOCKED') {
[171] Fix | Delete
log.warn('unlock' + name, unlockEr)
[172] Fix | Delete
}
[173] Fix | Delete
return cb.apply(null, args)
[174] Fix | Delete
}
[175] Fix | Delete
if (unlockEr) return cb(unlockEr)
[176] Fix | Delete
return cb.apply(null, args)
[177] Fix | Delete
}
[178] Fix | Delete
}
[179] Fix | Delete
}
[180] Fix | Delete
[181] Fix | Delete
function install (where, args, cb) {
[182] Fix | Delete
if (!cb) {
[183] Fix | Delete
cb = args
[184] Fix | Delete
args = where
[185] Fix | Delete
where = null
[186] Fix | Delete
}
[187] Fix | Delete
var globalTop = path.resolve(npm.globalDir, '..')
[188] Fix | Delete
if (!where) {
[189] Fix | Delete
where = npm.config.get('global')
[190] Fix | Delete
? globalTop
[191] Fix | Delete
: npm.prefix
[192] Fix | Delete
}
[193] Fix | Delete
validate('SAF', [where, args, cb])
[194] Fix | Delete
// the /path/to/node_modules/..
[195] Fix | Delete
var dryrun = !!npm.config.get('dry-run')
[196] Fix | Delete
[197] Fix | Delete
if (npm.config.get('dev')) {
[198] Fix | Delete
log.warn('install', 'Usage of the `--dev` option is deprecated. Use `--also=dev` instead.')
[199] Fix | Delete
}
[200] Fix | Delete
[201] Fix | Delete
if (where === globalTop && !args.length) {
[202] Fix | Delete
args = ['.']
[203] Fix | Delete
}
[204] Fix | Delete
args = args.filter(function (a) {
[205] Fix | Delete
return path.resolve(a) !== npm.prefix
[206] Fix | Delete
})
[207] Fix | Delete
[208] Fix | Delete
new Installer(where, dryrun, args).run(cb)
[209] Fix | Delete
}
[210] Fix | Delete
[211] Fix | Delete
function Installer (where, dryrun, args, opts) {
[212] Fix | Delete
validate('SBA|SBAO', arguments)
[213] Fix | Delete
if (!opts) opts = {}
[214] Fix | Delete
this.where = where
[215] Fix | Delete
this.dryrun = dryrun
[216] Fix | Delete
this.args = args
[217] Fix | Delete
// fakechildren are children created from the lockfile and lack relationship data
[218] Fix | Delete
// the only exist when the tree does not match the lockfile
[219] Fix | Delete
// this is fine when doing full tree installs/updates but not ok when modifying only
[220] Fix | Delete
// a few deps via `npm install` or `npm uninstall`.
[221] Fix | Delete
this.currentTree = null
[222] Fix | Delete
this.idealTree = null
[223] Fix | Delete
this.differences = []
[224] Fix | Delete
this.todo = []
[225] Fix | Delete
this.progress = {}
[226] Fix | Delete
this.noPackageJsonOk = !!args.length
[227] Fix | Delete
this.topLevelLifecycles = !args.length
[228] Fix | Delete
[229] Fix | Delete
this.autoPrune = npm.config.get('package-lock')
[230] Fix | Delete
[231] Fix | Delete
const dev = npm.config.get('dev')
[232] Fix | Delete
const only = npm.config.get('only')
[233] Fix | Delete
const onlyProd = /^prod(uction)?$/.test(only)
[234] Fix | Delete
const onlyDev = /^dev(elopment)?$/.test(only)
[235] Fix | Delete
const prod = npm.config.get('production')
[236] Fix | Delete
this.dev = opts.dev != null ? opts.dev : dev || (!onlyProd && !prod) || onlyDev
[237] Fix | Delete
this.prod = opts.prod != null ? opts.prod : !onlyDev
[238] Fix | Delete
[239] Fix | Delete
this.packageLockOnly = opts.packageLockOnly != null
[240] Fix | Delete
? opts.packageLockOnly : npm.config.get('package-lock-only')
[241] Fix | Delete
this.rollback = opts.rollback != null ? opts.rollback : npm.config.get('rollback')
[242] Fix | Delete
this.link = opts.link != null ? opts.link : npm.config.get('link')
[243] Fix | Delete
this.saveOnlyLock = opts.saveOnlyLock
[244] Fix | Delete
this.global = opts.global != null ? opts.global : this.where === path.resolve(npm.globalDir, '..')
[245] Fix | Delete
this.audit = npm.config.get('audit') && !this.global
[246] Fix | Delete
this.fund = npm.config.get('fund') && !this.global
[247] Fix | Delete
this.started = Date.now()
[248] Fix | Delete
}
[249] Fix | Delete
Installer.prototype = {}
[250] Fix | Delete
[251] Fix | Delete
Installer.prototype.run = function (_cb) {
[252] Fix | Delete
validate('F|', arguments)
[253] Fix | Delete
[254] Fix | Delete
var result
[255] Fix | Delete
var cb
[256] Fix | Delete
if (_cb) {
[257] Fix | Delete
cb = function (err) {
[258] Fix | Delete
saveMetrics(!err)
[259] Fix | Delete
return _cb.apply(this, arguments)
[260] Fix | Delete
}
[261] Fix | Delete
} else {
[262] Fix | Delete
result = new Promise((resolve, reject) => {
[263] Fix | Delete
cb = (err, value) => err ? reject(err) : resolve(value)
[264] Fix | Delete
})
[265] Fix | Delete
}
[266] Fix | Delete
// FIXME: This is bad and I should feel bad.
[267] Fix | Delete
// lib/install needs to have some way of sharing _limited_
[268] Fix | Delete
// state with the things it calls. Passing the object is too
[269] Fix | Delete
// much. The global config is WAY too much. =( =(
[270] Fix | Delete
// But not having this is gonna break linked modules in
[271] Fix | Delete
// subtle stupid ways, and refactoring all this code isn't
[272] Fix | Delete
// the right thing to do just yet.
[273] Fix | Delete
if (this.global) {
[274] Fix | Delete
var prevGlobal = npm.config.get('global')
[275] Fix | Delete
npm.config.set('global', true)
[276] Fix | Delete
var next = cb
[277] Fix | Delete
cb = function () {
[278] Fix | Delete
npm.config.set('global', prevGlobal)
[279] Fix | Delete
next.apply(null, arguments)
[280] Fix | Delete
}
[281] Fix | Delete
}
[282] Fix | Delete
[283] Fix | Delete
var installSteps = []
[284] Fix | Delete
var postInstallSteps = []
[285] Fix | Delete
if (!this.dryrun) {
[286] Fix | Delete
installSteps.push(
[287] Fix | Delete
[this.newTracker(log, 'runTopLevelLifecycles', 2)],
[288] Fix | Delete
[this, this.runPreinstallTopLevelLifecycles])
[289] Fix | Delete
}
[290] Fix | Delete
installSteps.push(
[291] Fix | Delete
[this.newTracker(log, 'loadCurrentTree', 4)],
[292] Fix | Delete
[this, this.loadCurrentTree],
[293] Fix | Delete
[this, this.finishTracker, 'loadCurrentTree'],
[294] Fix | Delete
[295] Fix | Delete
[this.newTracker(log, 'loadIdealTree', 12)],
[296] Fix | Delete
[this, this.loadIdealTree],
[297] Fix | Delete
[this, this.finishTracker, 'loadIdealTree'],
[298] Fix | Delete
[299] Fix | Delete
[this, this.debugTree, 'currentTree', 'currentTree'],
[300] Fix | Delete
[this, this.debugTree, 'idealTree', 'idealTree'],
[301] Fix | Delete
[302] Fix | Delete
[this.newTracker(log, 'generateActionsToTake')],
[303] Fix | Delete
[this, this.generateActionsToTake],
[304] Fix | Delete
[this, this.finishTracker, 'generateActionsToTake'],
[305] Fix | Delete
[306] Fix | Delete
[this, this.debugActions, 'diffTrees', 'differences'],
[307] Fix | Delete
[this, this.debugActions, 'decomposeActions', 'todo'],
[308] Fix | Delete
[this, this.startAudit]
[309] Fix | Delete
)
[310] Fix | Delete
[311] Fix | Delete
if (this.packageLockOnly) {
[312] Fix | Delete
postInstallSteps.push(
[313] Fix | Delete
[this, this.saveToDependencies])
[314] Fix | Delete
} else if (!this.dryrun) {
[315] Fix | Delete
installSteps.push(
[316] Fix | Delete
[this.newTracker(log, 'executeActions', 8)],
[317] Fix | Delete
[this, this.executeActions],
[318] Fix | Delete
[this, this.finishTracker, 'executeActions'])
[319] Fix | Delete
var node_modules = path.resolve(this.where, 'node_modules')
[320] Fix | Delete
var staging = path.resolve(node_modules, '.staging')
[321] Fix | Delete
postInstallSteps.push(
[322] Fix | Delete
[this.newTracker(log, 'rollbackFailedOptional', 1)],
[323] Fix | Delete
[this, this.rollbackFailedOptional, staging, this.todo],
[324] Fix | Delete
[this, this.finishTracker, 'rollbackFailedOptional'],
[325] Fix | Delete
[this, this.commit, staging, this.todo],
[326] Fix | Delete
[327] Fix | Delete
[this, this.runPostinstallTopLevelLifecycles],
[328] Fix | Delete
[this, this.finishTracker, 'runTopLevelLifecycles']
[329] Fix | Delete
)
[330] Fix | Delete
if (getSaveType()) {
[331] Fix | Delete
postInstallSteps.push(
[332] Fix | Delete
// this is necessary as we don't fill in `dependencies` and `devDependencies` in deps loaded from shrinkwrap
[333] Fix | Delete
// until after we extract them
[334] Fix | Delete
[this, (next) => { computeMetadata(this.idealTree); next() }],
[335] Fix | Delete
[this, this.pruneIdealTree],
[336] Fix | Delete
[this, this.debugLogicalTree, 'saveTree', 'idealTree'],
[337] Fix | Delete
[this, this.saveToDependencies])
[338] Fix | Delete
}
[339] Fix | Delete
}
[340] Fix | Delete
postInstallSteps.push(
[341] Fix | Delete
[this, this.printWarnings],
[342] Fix | Delete
[this, this.printInstalled])
[343] Fix | Delete
[344] Fix | Delete
var self = this
[345] Fix | Delete
chain(installSteps, function (installEr) {
[346] Fix | Delete
if (installEr) self.failing = true
[347] Fix | Delete
chain(postInstallSteps, function (postInstallEr) {
[348] Fix | Delete
if (installEr && postInstallEr) {
[349] Fix | Delete
var msg = errorMessage(postInstallEr)
[350] Fix | Delete
msg.summary.forEach(function (logline) {
[351] Fix | Delete
log.warn.apply(log, logline)
[352] Fix | Delete
})
[353] Fix | Delete
msg.detail.forEach(function (logline) {
[354] Fix | Delete
log.verbose.apply(log, logline)
[355] Fix | Delete
})
[356] Fix | Delete
}
[357] Fix | Delete
cb(installEr || postInstallEr, self.getInstalledModules(), self.idealTree)
[358] Fix | Delete
})
[359] Fix | Delete
})
[360] Fix | Delete
return result
[361] Fix | Delete
}
[362] Fix | Delete
[363] Fix | Delete
Installer.prototype.loadArgMetadata = function (next) {
[364] Fix | Delete
getAllMetadata(this.args, this.currentTree, process.cwd(), iferr(next, (args) => {
[365] Fix | Delete
this.args = args
[366] Fix | Delete
next()
[367] Fix | Delete
}))
[368] Fix | Delete
}
[369] Fix | Delete
[370] Fix | Delete
Installer.prototype.newTracker = function (tracker, name, size) {
[371] Fix | Delete
validate('OS', [tracker, name])
[372] Fix | Delete
if (size) validate('N', [size])
[373] Fix | Delete
this.progress[name] = tracker.newGroup(name, size)
[374] Fix | Delete
return function (next) {
[375] Fix | Delete
process.emit('time', 'stage:' + name)
[376] Fix | Delete
next()
[377] Fix | Delete
}
[378] Fix | Delete
}
[379] Fix | Delete
[380] Fix | Delete
Installer.prototype.finishTracker = function (name, cb) {
[381] Fix | Delete
validate('SF', arguments)
[382] Fix | Delete
process.emit('timeEnd', 'stage:' + name)
[383] Fix | Delete
cb()
[384] Fix | Delete
}
[385] Fix | Delete
[386] Fix | Delete
Installer.prototype.loadCurrentTree = function (cb) {
[387] Fix | Delete
validate('F', arguments)
[388] Fix | Delete
log.silly('install', 'loadCurrentTree')
[389] Fix | Delete
var todo = []
[390] Fix | Delete
if (this.global) {
[391] Fix | Delete
todo.push([this, this.readGlobalPackageData])
[392] Fix | Delete
} else {
[393] Fix | Delete
todo.push([this, this.readLocalPackageData])
[394] Fix | Delete
}
[395] Fix | Delete
todo.push([this, this.normalizeCurrentTree])
[396] Fix | Delete
chain(todo, cb)
[397] Fix | Delete
}
[398] Fix | Delete
[399] Fix | Delete
var createNode = require('./install/node.js').create
[400] Fix | Delete
var flatNameFromTree = require('./install/flatten-tree.js').flatNameFromTree
[401] Fix | Delete
Installer.prototype.normalizeCurrentTree = function (cb) {
[402] Fix | Delete
this.currentTree.isTop = true
[403] Fix | Delete
normalizeTree(this.currentTree)
[404] Fix | Delete
// If the user didn't have a package.json then fill in deps with what was on disk
[405] Fix | Delete
if (this.currentTree.error) {
[406] Fix | Delete
for (let child of this.currentTree.children) {
[407] Fix | Delete
if (!child.fakeChild && isExtraneous(child)) {
[408] Fix | Delete
this.currentTree.package.dependencies[moduleName(child)] = computeVersionSpec(this.currentTree, child)
[409] Fix | Delete
}
[410] Fix | Delete
}
[411] Fix | Delete
}
[412] Fix | Delete
computeMetadata(this.currentTree)
[413] Fix | Delete
return cb()
[414] Fix | Delete
[415] Fix | Delete
function normalizeTree (tree, seen) {
[416] Fix | Delete
if (!seen) seen = new Set()
[417] Fix | Delete
if (seen.has(tree)) return
[418] Fix | Delete
seen.add(tree)
[419] Fix | Delete
createNode(tree)
[420] Fix | Delete
tree.location = flatNameFromTree(tree)
[421] Fix | Delete
tree.children.forEach((child) => normalizeTree(child, seen))
[422] Fix | Delete
}
[423] Fix | Delete
}
[424] Fix | Delete
[425] Fix | Delete
Installer.prototype.loadIdealTree = function (cb) {
[426] Fix | Delete
validate('F', arguments)
[427] Fix | Delete
log.silly('install', 'loadIdealTree')
[428] Fix | Delete
[429] Fix | Delete
chain([
[430] Fix | Delete
[this.newTracker(this.progress.loadIdealTree, 'loadIdealTree:cloneCurrentTree')],
[431] Fix | Delete
[this, this.cloneCurrentTreeToIdealTree],
[432] Fix | Delete
[this, this.finishTracker, 'loadIdealTree:cloneCurrentTree'],
[433] Fix | Delete
[434] Fix | Delete
[this.newTracker(this.progress.loadIdealTree, 'loadIdealTree:loadShrinkwrap')],
[435] Fix | Delete
[this, this.loadShrinkwrap],
[436] Fix | Delete
[this, this.finishTracker, 'loadIdealTree:loadShrinkwrap'],
[437] Fix | Delete
[438] Fix | Delete
[this.newTracker(this.progress.loadIdealTree, 'loadIdealTree:loadAllDepsIntoIdealTree', 10)],
[439] Fix | Delete
[this, this.loadAllDepsIntoIdealTree],
[440] Fix | Delete
[this, this.finishTracker, 'loadIdealTree:loadAllDepsIntoIdealTree'],
[441] Fix | Delete
[this, function (next) { computeMetadata(this.idealTree); next() }],
[442] Fix | Delete
[this, this.pruneIdealTree]
[443] Fix | Delete
], cb)
[444] Fix | Delete
}
[445] Fix | Delete
[446] Fix | Delete
Installer.prototype.pruneIdealTree = function (cb) {
[447] Fix | Delete
if (!this.idealTree) return cb()
[448] Fix | Delete
// if our lock file didn't have the requires field and there
[449] Fix | Delete
// are any fake children then forgo pruning until we have more info.
[450] Fix | Delete
if (!this.idealTree.hasRequiresFromLock && this.idealTree.children.some((n) => n.fakeChild)) return cb()
[451] Fix | Delete
const toPrune = this.idealTree.children
[452] Fix | Delete
.filter((child) => isExtraneous(child) && (this.autoPrune || child.removing))
[453] Fix | Delete
.map((n) => ({name: moduleName(n)}))
[454] Fix | Delete
return removeExtraneous(toPrune, this.idealTree, cb)
[455] Fix | Delete
}
[456] Fix | Delete
[457] Fix | Delete
Installer.prototype.loadAllDepsIntoIdealTree = function (cb) {
[458] Fix | Delete
validate('F', arguments)
[459] Fix | Delete
log.silly('install', 'loadAllDepsIntoIdealTree')
[460] Fix | Delete
var saveDeps = getSaveType()
[461] Fix | Delete
[462] Fix | Delete
var cg = this.progress['loadIdealTree:loadAllDepsIntoIdealTree']
[463] Fix | Delete
var installNewModules = !!this.args.length
[464] Fix | Delete
var steps = []
[465] Fix | Delete
[466] Fix | Delete
if (installNewModules) {
[467] Fix | Delete
steps.push([validateArgs, this.idealTree, this.args])
[468] Fix | Delete
steps.push([loadRequestedDeps, this.args, this.idealTree, saveDeps, cg.newGroup('loadRequestedDeps')])
[469] Fix | Delete
} else {
[470] Fix | Delete
const depsToPreload = Object.assign({},
[471] Fix | Delete
this.idealTree.package.devDependencies,
[472] Fix | Delete
this.idealTree.package.dependencies
[473] Fix | Delete
)
[474] Fix | Delete
steps.push(
[475] Fix | Delete
[prefetchDeps, this.idealTree, depsToPreload, cg.newGroup('prefetchDeps')],
[476] Fix | Delete
[loadDeps, this.idealTree, cg.newGroup('loadDeps')],
[477] Fix | Delete
[loadDevDeps, this.idealTree, cg.newGroup('loadDevDeps')])
[478] Fix | Delete
}
[479] Fix | Delete
steps.push(
[480] Fix | Delete
[loadExtraneous.andResolveDeps, this.idealTree, cg.newGroup('loadExtraneous')])
[481] Fix | Delete
chain(steps, cb)
[482] Fix | Delete
}
[483] Fix | Delete
[484] Fix | Delete
Installer.prototype.generateActionsToTake = function (cb) {
[485] Fix | Delete
validate('F', arguments)
[486] Fix | Delete
log.silly('install', 'generateActionsToTake')
[487] Fix | Delete
var cg = this.progress.generateActionsToTake
[488] Fix | Delete
chain([
[489] Fix | Delete
[validateTree, this.idealTree, cg.newGroup('validateTree')],
[490] Fix | Delete
[diffTrees, this.currentTree, this.idealTree, this.differences, cg.newGroup('diffTrees')],
[491] Fix | Delete
[this, this.computeLinked],
[492] Fix | Delete
[checkPermissions, this.differences],
[493] Fix | Delete
[decomposeActions, this.differences, this.todo]
[494] Fix | Delete
], cb)
[495] Fix | Delete
}
[496] Fix | Delete
[497] Fix | Delete
Installer.prototype.computeLinked = function (cb) {
[498] Fix | Delete
validate('F', arguments)
[499] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function