Skip to content

Instantly share code, notes, and snippets.

@isaacs
Created October 20, 2021 15:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save isaacs/e1fdd2d2fadae662d1295b69c8932ba9 to your computer and use it in GitHub Desktop.
Save isaacs/e1fdd2d2fadae662d1295b69c8932ba9 to your computer and use it in GitHub Desktop.
diff --git a/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js b/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js
index ed0e47daf..1d4e20292 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/load-virtual.js
@@ -308,11 +308,13 @@ module.exports = cls => class VirtualLoader extends cls {
target,
pkg: target && target.package,
})
- link.extraneous = target.extraneous
- link.devOptional = target.devOptional
- link.peer = target.peer
- link.optional = target.optional
- link.dev = target.dev
+ if (target) {
+ link.extraneous = target.extraneous
+ link.devOptional = target.devOptional
+ link.peer = target.peer
+ link.optional = target.optional
+ link.dev = target.dev
+ }
return link
}
}
diff --git a/node_modules/@npmcli/arborist/lib/arborist/rebuild.js b/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
index 4f3fc1b9c..24ed819fe 100644
--- a/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
+++ b/node_modules/@npmcli/arborist/lib/arborist/rebuild.js
@@ -225,6 +225,10 @@ module.exports = cls => class Builder extends cls {
!(meta.originalLockfileVersion >= 2)
}
+ if (!node.target) {
+ return
+ }
+
const { package: pkg, hasInstallScript } = node.target
const { gypfile, bin, scripts = {} } = pkg
diff --git a/node_modules/@npmcli/arborist/lib/calc-dep-flags.js b/node_modules/@npmcli/arborist/lib/calc-dep-flags.js
index 95ecc8a61..9f9113e11 100644
--- a/node_modules/@npmcli/arborist/lib/calc-dep-flags.js
+++ b/node_modules/@npmcli/arborist/lib/calc-dep-flags.js
@@ -31,6 +31,9 @@ const calcDepFlagsStep = (node) => {
// for links, map their hierarchy appropriately
if (node.isLink) {
+ if (!node.target) {
+ return node
+ }
node.target.dev = node.dev
node.target.optional = node.optional
node.target.devOptional = node.devOptional
@@ -100,11 +103,12 @@ const unsetFlag = (node, flag) => {
tree: node,
visit: node => {
node.extraneous = node[flag] = false
- if (node.isLink) {
+ if (node.isLink && node.target) {
node.target.extraneous = node.target[flag] = false
}
},
- getChildren: node => [...node.target.edgesOut.values()]
+ getChildren: node => !node.target ? []
+ : [...node.target.edgesOut.values()]
.filter(edge => edge.to && edge.to[flag] &&
(flag !== 'peer' && edge.type === 'peer' || edge.type === 'prod'))
.map(edge => edge.to),
diff --git a/node_modules/@npmcli/arborist/lib/shrinkwrap.js b/node_modules/@npmcli/arborist/lib/shrinkwrap.js
index 93e1cb1a4..7a777b1b3 100644
--- a/node_modules/@npmcli/arborist/lib/shrinkwrap.js
+++ b/node_modules/@npmcli/arborist/lib/shrinkwrap.js
@@ -1023,6 +1023,9 @@ class Shrinkwrap {
}
const depender = node.target
+ if (!depender) {
+ return lock
+ }
if (depender.edgesOut.size > 0) {
if (node !== this.tree) {
const entries = [...depender.edgesOut.entries()]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment