diff options
author | Anna Henningsen <anna@addaleax.net> | 2018-04-05 22:51:49 +0200 |
---|---|---|
committer | Anna Henningsen <anna@addaleax.net> | 2018-04-05 23:00:02 +0200 |
commit | e37effe4cec98688e75d770f4d0b7f68927e2b73 (patch) | |
tree | e7efa0fc8a2139f9aba4b66ea3f3613262f20cef /deps/npm/lib/install/deps.js | |
parent | 026f6b787a7a23597790f1f0b076c58a68c7c38b (diff) | |
download | android-node-v8-e37effe4cec98688e75d770f4d0b7f68927e2b73.tar.gz android-node-v8-e37effe4cec98688e75d770f4d0b7f68927e2b73.tar.bz2 android-node-v8-e37effe4cec98688e75d770f4d0b7f68927e2b73.zip |
Revert "deps: upgrade npm to 5.8.0"
This reverts commit 25a816dcda7b1db0929501acfe13f2fe5119759b.
PR-URL: https://github.com/nodejs/node/pull/19837
Reviewed-By: Gus Caplan <me@gus.host>
Diffstat (limited to 'deps/npm/lib/install/deps.js')
-rw-r--r-- | deps/npm/lib/install/deps.js | 75 |
1 files changed, 8 insertions, 67 deletions
diff --git a/deps/npm/lib/install/deps.js b/deps/npm/lib/install/deps.js index 54cc5258fa..93c4adffd7 100644 --- a/deps/npm/lib/install/deps.js +++ b/deps/npm/lib/install/deps.js @@ -33,7 +33,6 @@ var getSaveType = require('./save.js').getSaveType var unixFormatPath = require('../utils/unix-format-path.js') var isExtraneous = require('./is-extraneous.js') var isRegistry = require('../utils/is-registry.js') -var hasModernMeta = require('./has-modern-meta.js') // The export functions in this module mutate a dependency tree, adding // items to them. @@ -112,7 +111,7 @@ function computeMetadata (tree, seen) { const reqs = tree.swRequires || {} for (let name of Object.keys(deps)) { if (findChild(name, deps[name])) continue - if (name in reqs && findChild(name, reqs[name])) continue + if (findChild(name, reqs[name])) continue tree.missingDeps[name] = deps[name] } if (tree.isTop) { @@ -333,21 +332,9 @@ exports.removeDeps = function (args, tree, saveToDependencies, next) { parent.requires = parent.requires.filter((child) => child !== pkgToRemove) } pkgToRemove.requiredBy = pkgToRemove.requiredBy.filter((parent) => parent !== tree) - flagAsRemoving(pkgToRemove) } next() } - -function flagAsRemoving (toRemove, seen) { - if (!seen) seen = new Set() - if (seen.has(toRemove)) return - seen.add(toRemove) - toRemove.removing = true - toRemove.requires.forEach((required) => { - flagAsRemoving(required, seen) - }) -} - exports.removeExtraneous = function (args, tree, next) { for (let pkg of args) { var pkgName = moduleName(pkg) @@ -539,7 +526,7 @@ function addDependency (name, versionSpec, tree, log, done) { } var child = findRequirement(tree, name, req) if (!child && swReq) child = findRequirement(tree, name, swReq) - if (hasModernMeta(child)) { + if (child) { resolveWithExistingModule(child, tree) if (child.package._shrinkwrap === undefined) { readShrinkwrap.andInflate(child, function (er) { next(er, child, log) }) @@ -547,42 +534,12 @@ function addDependency (name, versionSpec, tree, log, done) { next(null, child, log) } } else { - if (child) { - if (req.registry) { - req = childDependencySpecifier(tree, name, child.package.version) - } - if (child.fromBundle) reportBundleOverride(child, log) - removeObsoleteDep(child, log) - } fetchPackageMetadata(req, packageRelativePath(tree), {tracker: log.newItem('fetchMetadata')}, iferr(next, function (pkg) { resolveWithNewModule(pkg, tree, log, next) })) } } -function getTop (pkg) { - const seen = new Set() - while (pkg.parent && !seen.has(pkg.parent)) { - pkg = pkg.parent - seen.add(pkg) - } - return pkg -} - -function reportBundleOverride (child, log) { - const code = 'EBUNDLEOVERRIDE' - const top = getTop(child.fromBundle) - const bundlerId = packageId(child.fromBundle) - if (!top.warnings.some((w) => { - return w.code === code - })) { - const err = new Error(`${bundlerId} had bundled packages that do not match the required version(s). They have been replaced with non-bundled versions.`) - err.code = code - top.warnings.push(err) - } - if (log) log.verbose('bundle', `${code}: Replacing ${bundlerId}'s bundled version of ${moduleName(child)} with ${packageId(child)}.`) -} - function resolveWithExistingModule (child, tree) { validate('OO', arguments) addRequiredDep(tree, child) @@ -635,7 +592,7 @@ function resolveWithNewModule (pkg, tree, log, next) { return isInstallable(pkg, (err) => { let installable = !err addBundled(pkg, (bundleErr) => { - var parent = earliestInstallable(tree, tree, pkg, log) || tree + var parent = earliestInstallable(tree, tree, pkg) || tree var isLink = pkg._requested.type === 'directory' var child = createChild({ package: pkg, @@ -652,10 +609,7 @@ function resolveWithNewModule (pkg, tree, log, next) { var hasBundled = child.children.length var replaced = replaceModuleByName(parent, 'children', child) - if (replaced) { - if (replaced.fromBundle) reportBundleOverride(replaced, log) - removeObsoleteDep(replaced) - } + if (replaced) removeObsoleteDep(replaced) addRequiredDep(tree, child) child.location = flatNameFromTree(child) @@ -740,25 +694,12 @@ function preserveSymlinks () { // Find the highest level in the tree that we can install this module in. // If the module isn't installed above us yet, that'd be the very top. // If it is, then it's the level below where its installed. -var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg, log) { - validate('OOOO', arguments) - +var earliestInstallable = exports.earliestInstallable = function (requiredBy, tree, pkg) { + validate('OOO', arguments) function undeletedModuleMatches (child) { return !child.removed && moduleName(child) === pkg.name } - const undeletedMatches = tree.children.filter(undeletedModuleMatches) - if (undeletedMatches.length) { - // if there's a conflict with another child AT THE SAME level then we're replacing it, so - // mark it as removed and continue with resolution normally. - if (tree === requiredBy) { - undeletedMatches.forEach((pkg) => { - if (pkg.fromBundle) reportBundleOverride(pkg, log) - removeObsoleteDep(pkg, log) - }) - } else { - return null - } - } + if (tree.children.some(undeletedModuleMatches)) return null // If any of the children of this tree have conflicting // binaries then we need to decline to install this package here. @@ -797,5 +738,5 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr if (!preserveSymlinks() && /^[.][.][\\/]/.test(path.relative(tree.parent.realpath, tree.realpath))) return tree - return (earliestInstallable(requiredBy, tree.parent, pkg, log) || tree) + return (earliestInstallable(requiredBy, tree.parent, pkg) || tree) } |