summaryrefslogtreecommitdiff
path: root/deps/npm/lib/install
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/lib/install')
-rw-r--r--deps/npm/lib/install/action/extract.js3
-rw-r--r--deps/npm/lib/install/action/global-install.js3
-rw-r--r--deps/npm/lib/install/action/global-link.js3
-rw-r--r--deps/npm/lib/install/and-add-parent-to-errors.js3
-rw-r--r--deps/npm/lib/install/deps.js32
-rw-r--r--deps/npm/lib/install/inflate-shrinkwrap.js2
-rw-r--r--deps/npm/lib/install/is-only-optional.js3
-rw-r--r--deps/npm/lib/install/save.js2
8 files changed, 38 insertions, 13 deletions
diff --git a/deps/npm/lib/install/action/extract.js b/deps/npm/lib/install/action/extract.js
index c1c17cdf6c..32a4f4e004 100644
--- a/deps/npm/lib/install/action/extract.js
+++ b/deps/npm/lib/install/action/extract.js
@@ -6,6 +6,7 @@ const figgyPudding = require('figgy-pudding')
const stat = BB.promisify(require('graceful-fs').stat)
const gentlyRm = BB.promisify(require('../../utils/gently-rm.js'))
const mkdirp = BB.promisify(require('mkdirp'))
+const moduleName = require('../../utils/module-name.js')
const moduleStagingPath = require('../module-staging-path.js')
const move = require('../../utils/move.js')
const npa = require('npm-package-arg')
@@ -113,7 +114,7 @@ function readBundled (pkg, staging, extractTo) {
}
function stageBundledModule (bundler, child, staging, parentPath) {
- const stageFrom = path.join(parentPath, 'node_modules', child.package.name)
+ const stageFrom = path.join(parentPath, 'node_modules', moduleName(child))
const stageTo = moduleStagingPath(staging, child)
return BB.map(child.children, (child) => {
diff --git a/deps/npm/lib/install/action/global-install.js b/deps/npm/lib/install/action/global-install.js
index bdc121b693..44d2f628f2 100644
--- a/deps/npm/lib/install/action/global-install.js
+++ b/deps/npm/lib/install/action/global-install.js
@@ -3,12 +3,13 @@ var path = require('path')
var npm = require('../../npm.js')
var Installer = require('../../install.js').Installer
var packageId = require('../../utils/package-id.js')
+var moduleName = require('../../utils/module-name.js')
module.exports = function (staging, pkg, log, next) {
log.silly('global-install', packageId(pkg))
var globalRoot = path.resolve(npm.globalDir, '..')
npm.config.set('global', true)
- var install = new Installer(globalRoot, false, [pkg.package.name + '@' + pkg.package._requested.fetchSpec])
+ var install = new Installer(globalRoot, false, [moduleName(pkg) + '@' + pkg.package._requested.rawSpec])
install.link = false
install.run(function () {
npm.config.set('global', false)
diff --git a/deps/npm/lib/install/action/global-link.js b/deps/npm/lib/install/action/global-link.js
index f109e5b88a..c9d9a8feb2 100644
--- a/deps/npm/lib/install/action/global-link.js
+++ b/deps/npm/lib/install/action/global-link.js
@@ -1,8 +1,9 @@
'use strict'
+var moduleName = require('../../utils/module-name.js')
var npm = require('../../npm.js')
var packageId = require('../../utils/package-id.js')
module.exports = function (staging, pkg, log, next) {
log.silly('global-link', packageId(pkg))
- npm.link(pkg.package.name, next)
+ npm.link(moduleName(pkg), next)
}
diff --git a/deps/npm/lib/install/and-add-parent-to-errors.js b/deps/npm/lib/install/and-add-parent-to-errors.js
index 62a86bd4a6..fe4128230b 100644
--- a/deps/npm/lib/install/and-add-parent-to-errors.js
+++ b/deps/npm/lib/install/and-add-parent-to-errors.js
@@ -1,4 +1,5 @@
'use strict'
+var moduleName = require('../utils/module-name.js')
var validate = require('aproba')
module.exports = function (parent, cb) {
@@ -6,7 +7,7 @@ module.exports = function (parent, cb) {
return function (er) {
if (!er) return cb.apply(null, arguments)
if (er instanceof Error && parent && parent.package && parent.package.name) {
- er.parent = parent.package.name
+ er.parent = moduleName(parent)
}
cb(er)
}
diff --git a/deps/npm/lib/install/deps.js b/deps/npm/lib/install/deps.js
index c36265093b..3fe370140a 100644
--- a/deps/npm/lib/install/deps.js
+++ b/deps/npm/lib/install/deps.js
@@ -57,6 +57,19 @@ function doesChildVersionMatch (child, requested, requestor) {
if (fromSw.toString() === requested.toString()) return true
}
+ if (requested.type === 'git' && requested.gitRange) {
+ const sameRepo = npa(child.package._from).fetchSpec === requested.fetchSpec
+ try {
+ return sameRepo && semver.satisfies(child.package.version, requested.gitRange, true)
+ } catch (e) {
+ return false
+ }
+ }
+
+ if (requested.type === 'alias') {
+ return doesChildVersionMatch(child, requested.subSpec, requestor)
+ }
+
if (!registryTypes[requested.type]) {
var childReq = child.package._requested
if (childReq) {
@@ -72,7 +85,7 @@ function doesChildVersionMatch (child, requested, requestor) {
// You'll see this scenario happen with at least tags and git dependencies.
// Some buggy clients will write spaces into the module name part of a _from.
if (child.package._from) {
- var fromReq = npa.resolve(moduleName(child), child.package._from.replace(new RegExp('^\\s*' + moduleName(child) + '\\s*@'), ''))
+ var fromReq = npa(child.package._from)
if (fromReq.rawSpec === requested.rawSpec) return true
if (fromReq.type === requested.type && fromReq.saveSpec && fromReq.saveSpec === requested.saveSpec) return true
}
@@ -289,11 +302,13 @@ function computeVersionSpec (tree, child) {
var requested
var childReq = child.package._requested
if (child.isLink) {
- requested = npa.resolve(child.package.name, 'file:' + child.realpath, getTop(tree).path)
+ requested = npa.resolve(moduleName(child), 'file:' + child.realpath, getTop(tree).path)
} else if (childReq && (isNotEmpty(childReq.saveSpec) || (isNotEmpty(childReq.rawSpec) && isNotEmpty(childReq.fetchSpec)))) {
requested = child.package._requested
} else if (child.package._from) {
requested = npa(child.package._from, tree.path)
+ } else if (child.name && child.name !== child.package.name) {
+ requested = npa.resolve(child.name, `npm:${child.package.name}@${child.package.version})`)
} else {
requested = npa.resolve(child.package.name, child.package.version)
}
@@ -305,6 +320,9 @@ function computeVersionSpec (tree, child) {
!npm.config.get('save-exact')) {
rangeDescriptor = npm.config.get('save-prefix')
}
+ if (requested.type === 'alias') {
+ rangeDescriptor = `npm:${requested.subSpec.name}@${rangeDescriptor}`
+ }
return rangeDescriptor + version
} else if (requested.type === 'directory' || requested.type === 'file') {
return 'file:' + unixFormatPath(path.relative(getTop(tree).path, requested.fetchSpec))
@@ -324,7 +342,7 @@ exports.removeDeps = function (args, tree, saveToDependencies, next) {
for (let pkg of args) {
var pkgName = moduleName(pkg)
var toRemove = tree.children.filter(moduleNameMatches(pkgName))
- var pkgToRemove = toRemove[0] || createChild({package: {name: pkgName}})
+ var pkgToRemove = toRemove[0] || createChild({name: pkgName})
var saveType = getSaveType(tree, pkg) || 'dependencies'
if (tree.isTop && saveToDependencies) {
pkgToRemove.save = saveType
@@ -652,11 +670,13 @@ function resolveWithNewModule (pkg, tree, log, next) {
addBundled(pkg, (bundleErr) => {
var parent = earliestInstallable(tree, tree, pkg, log) || tree
var isLink = pkg._requested.type === 'directory'
+ var name = pkg._requested.name || pkg.name
var child = createChild({
+ name,
package: pkg,
parent: parent,
- path: path.join(parent.isLink ? parent.realpath : parent.path, 'node_modules', pkg.name),
- realpath: isLink ? pkg._requested.fetchSpec : path.join(parent.realpath, 'node_modules', pkg.name),
+ path: path.join(parent.isLink ? parent.realpath : parent.path, 'node_modules', name),
+ realpath: isLink ? pkg._requested.fetchSpec : path.join(parent.realpath, 'node_modules', name),
children: pkg._bundled || [],
isLink: isLink,
isInLink: parent.isLink,
@@ -759,7 +779,7 @@ var earliestInstallable = exports.earliestInstallable = function (requiredBy, tr
validate('OOOO', arguments)
function undeletedModuleMatches (child) {
- return !child.removed && moduleName(child) === pkg.name
+ return !child.removed && moduleName(child) === ((pkg._requested && pkg._requested.name) || pkg.name)
}
const undeletedMatches = tree.children.filter(undeletedModuleMatches)
if (undeletedMatches.length) {
diff --git a/deps/npm/lib/install/inflate-shrinkwrap.js b/deps/npm/lib/install/inflate-shrinkwrap.js
index bf1ab70657..395cc11191 100644
--- a/deps/npm/lib/install/inflate-shrinkwrap.js
+++ b/deps/npm/lib/install/inflate-shrinkwrap.js
@@ -177,7 +177,7 @@ function makeFakeChild (name, topPath, tree, sw, requested) {
realpath: requested.type === 'directory' ? requested.fetchSpec : childPath(tree.realpath, pkg),
location: (tree.location === '/' ? '' : tree.location + '/') + pkg.name,
isLink: requested.type === 'directory',
- isInLink: tree.isLink,
+ isInLink: tree.isLink || tree.isInLink,
swRequires: sw.requires
})
tree.children.push(child)
diff --git a/deps/npm/lib/install/is-only-optional.js b/deps/npm/lib/install/is-only-optional.js
index f1b731578d..81e227bae7 100644
--- a/deps/npm/lib/install/is-only-optional.js
+++ b/deps/npm/lib/install/is-only-optional.js
@@ -2,6 +2,7 @@
module.exports = isOptional
const isOptDep = require('./is-opt-dep.js')
+const moduleName = require('../utils/module-name.js')
function isOptional (node, seen) {
if (!seen) seen = new Set()
@@ -15,6 +16,6 @@ function isOptional (node, seen) {
const swOptional = node.fromShrinkwrap && node.package._optional
return node.requiredBy.every(function (req) {
if (req.fakeChild && swOptional) return true
- return isOptDep(req, node.package.name) || isOptional(req, seen)
+ return isOptDep(req, moduleName(node)) || isOptional(req, seen)
})
}
diff --git a/deps/npm/lib/install/save.js b/deps/npm/lib/install/save.js
index 7227e78852..92b44a1080 100644
--- a/deps/npm/lib/install/save.js
+++ b/deps/npm/lib/install/save.js
@@ -44,7 +44,7 @@ exports.saveShrinkwrap = saveShrinkwrap
function saveShrinkwrap (tree, next) {
validate('OF', arguments)
- if (!npm.config.get('shrinkwrap') || !npm.config.get('package-lock')) {
+ if (!npm.config.get('package-lock-only') && (!npm.config.get('shrinkwrap') || !npm.config.get('package-lock'))) {
return next()
}
require('../shrinkwrap.js').createShrinkwrap(tree, {silent: false}, next)