Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Fix error reading matches of null when install dependencies #7588

Open
wants to merge 2 commits into
base: latest
Choose a base branch
from
Open
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 @@
}

// 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;

Check failure on line 1119 in workspaces/arborist/lib/node.js

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
}
return this.target.matches(node.target);

Check failure on line 1121 in workspaces/arborist/lib/node.js

View workflow job for this annotation

GitHub Actions / Lint

Extra semicolon
}

// 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 treeCheck = require('../lib/tree-check.js')

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

Check failure on line 11 in workspaces/arborist/test/node.js

View workflow job for this annotation

GitHub Actions / Lint

'realpath' is assigned a value but never used

t.cleanSnapshot = str =>
str.split(process.cwd()).join('{CWD}')
Expand Down Expand Up @@ -1548,6 +1549,13 @@
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
Loading