Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions workspaces/arborist/lib/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,12 @@ class Node {
}

// if they're links, they match if the targets match
if (this.isLink) {
return node.isLink && this.target.matches(node.target)
if (node.isLink) {
// Linked to nothing, cannot matches
if (!this.target || !node.target) {
return false;
}
return this.target.matches(node.target);
}

// if they're two project root nodes, they're different if the paths differ
Expand Down
8 changes: 8 additions & 0 deletions workspaces/arborist/test/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const { resolve } = require('node:path')
const treeCheck = require('../lib/tree-check.js')

const { normalizePath, normalizePaths } = require('./fixtures/utils.js')
const { realpath } = require('node:fs')

t.cleanSnapshot = str =>
str.split(process.cwd()).join('{CWD}')
Expand Down Expand Up @@ -1548,6 +1549,13 @@ t.test('detect that two nodes are the same thing', async t => {
const b = new Node({ parent: a, pkg: pkgb })
check(a, b, false, 'name/version mismatch, if no resolved/integrity')
}

{
const root = new Node({ path: '/x' })
const a = new Link({ root, path: '/a', realpath: '/a', target: null })
const b = new Link({ root, path: '/b', realpath: '/b', target: null })
check(a, b, false, 'links does not match if target to null')
}
})

t.test('node.satisfies(requested)', t => {
Expand Down