@npmcli/arborist 4.3.0 → 4.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1250,24 +1250,40 @@ This is a one-time fix-up, please be patient...
1250
1250
  // Don't bother to load the manifest for link deps, because the target
1251
1251
  // might be within another package that doesn't exist yet.
1252
1252
  const { legacyPeerDeps } = this
1253
- return spec.type === 'directory'
1254
- ? this[_linkFromSpec](name, spec, parent, edge)
1255
- : this[_fetchManifest](spec)
1256
- .then(pkg => new Node({ name, pkg, parent, legacyPeerDeps }), error => {
1257
- error.requiredBy = edge.from.location || '.'
1258
-
1259
- // failed to load the spec, either because of enotarget or
1260
- // fetch failure of some other sort. save it so we can verify
1261
- // later that it's optional, otherwise the error is fatal.
1262
- const n = new Node({
1263
- name,
1264
- parent,
1265
- error,
1266
- legacyPeerDeps,
1267
- })
1268
- this[_loadFailures].add(n)
1269
- return n
1253
+
1254
+ // spec is a directory, link it
1255
+ if (spec.type === 'directory') {
1256
+ return this[_linkFromSpec](name, spec, parent, edge)
1257
+ }
1258
+
1259
+ // if the spec matches a workspace name, then see if the workspace node will
1260
+ // satisfy the edge. if it does, we return the workspace node to make sure it
1261
+ // takes priority.
1262
+ if (this.idealTree.workspaces && this.idealTree.workspaces.has(spec.name)) {
1263
+ const existingNode = this.idealTree.edgesOut.get(spec.name).to
1264
+ if (existingNode && existingNode.isWorkspace && existingNode.satisfies(edge)) {
1265
+ return edge.to
1266
+ }
1267
+ }
1268
+
1269
+ // spec isn't a directory, and either isn't a workspace or the workspace we have
1270
+ // doesn't satisfy the edge. try to fetch a manifest and build a node from that.
1271
+ return this[_fetchManifest](spec)
1272
+ .then(pkg => new Node({ name, pkg, parent, legacyPeerDeps }), error => {
1273
+ error.requiredBy = edge.from.location || '.'
1274
+
1275
+ // failed to load the spec, either because of enotarget or
1276
+ // fetch failure of some other sort. save it so we can verify
1277
+ // later that it's optional, otherwise the error is fatal.
1278
+ const n = new Node({
1279
+ name,
1280
+ parent,
1281
+ error,
1282
+ legacyPeerDeps,
1270
1283
  })
1284
+ this[_loadFailures].add(n)
1285
+ return n
1286
+ })
1271
1287
  }
1272
1288
 
1273
1289
  [_linkFromSpec] (name, spec, parent, edge) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@npmcli/arborist",
3
- "version": "4.3.0",
3
+ "version": "4.3.1",
4
4
  "description": "Manage node_modules trees",
5
5
  "dependencies": {
6
6
  "@isaacs/string-locale-compare": "^1.1.0",