Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/@npmcli/arborist/lib/node.js')
-rw-r--r--deps/npm/node_modules/@npmcli/arborist/lib/node.js40
1 files changed, 31 insertions, 9 deletions
diff --git a/deps/npm/node_modules/@npmcli/arborist/lib/node.js b/deps/npm/node_modules/@npmcli/arborist/lib/node.js
index d77b18355ff..5616019dd9c 100644
--- a/deps/npm/node_modules/@npmcli/arborist/lib/node.js
+++ b/deps/npm/node_modules/@npmcli/arborist/lib/node.js
@@ -66,6 +66,7 @@ const relpath = require('./relpath.js')
const consistentResolve = require('./consistent-resolve.js')
const printableTree = require('./printable.js')
+const CaseInsensitiveMap = require('./case-insensitive-map.js')
class Node {
constructor (options) {
@@ -148,7 +149,7 @@ class Node {
this.hasShrinkwrap = hasShrinkwrap || pkg._hasShrinkwrap || false
this.legacyPeerDeps = legacyPeerDeps
- this.children = new Map()
+ this.children = new CaseInsensitiveMap()
this.fsChildren = new Set()
this.inventory = new Inventory({})
this.tops = new Set()
@@ -181,7 +182,7 @@ class Node {
}
this.edgesIn = new Set()
- this.edgesOut = new Map()
+ this.edgesOut = new CaseInsensitiveMap()
// have to set the internal package ref before assigning the parent,
// because this.package is read when adding to inventory
@@ -248,7 +249,7 @@ class Node {
// true for packages installed directly in the global node_modules folder
get globalTop () {
- return this.global && this.parent.isProjectRoot
+ return this.global && this.parent && this.parent.isProjectRoot
}
get workspaces () {
@@ -478,6 +479,9 @@ class Node {
}
get isProjectRoot () {
+ // only treat as project root if it's the actual link that is the root,
+ // or the target of the root link, but NOT if it's another link to the
+ // same root that happens to be somewhere else.
return this === this.root || this === this.root.target
}
@@ -772,9 +776,15 @@ class Node {
this[_loadDepType](this.package.dependencies, 'prod')
this[_loadDepType](this.package.optionalDependencies, 'optional')
- const { isTop, path, sourceReference } = this
- const { isTop: srcTop, path: srcPath } = sourceReference || {}
- if (isTop && path && (!sourceReference || srcTop && srcPath))
+ const { globalTop, isTop, path, sourceReference } = this
+ const {
+ globalTop: srcGlobalTop,
+ isTop: srcTop,
+ path: srcPath,
+ } = sourceReference || {}
+ const thisDev = isTop && !globalTop && path
+ const srcDev = !sourceReference || srcTop && !srcGlobalTop && srcPath
+ if (thisDev && srcDev)
this[_loadDepType](this.package.devDependencies, 'dev')
}
@@ -1014,8 +1024,20 @@ class Node {
replace (node) {
this[_delistFromMeta]()
- this.path = node.path
- this.name = node.name
+
+ // if the name matches, but is not identical, we are intending to clobber
+ // something case-insensitively, so merely setting name and path won't
+ // have the desired effect. just set the path so it'll collide in the
+ // parent's children map, and leave it at that.
+ const nameMatch = node.parent &&
+ node.parent.children.get(this.name) === node
+ if (nameMatch)
+ this.path = resolve(node.parent.path, 'node_modules', this.name)
+ else {
+ this.path = node.path
+ this.name = node.name
+ }
+
if (!this.isLink)
this.realpath = this.path
this[_refreshLocation]()
@@ -1210,7 +1232,7 @@ class Node {
}
get isTop () {
- return !this.parent
+ return !this.parent || this.globalTop
}
get top () {