Skip to content

Commit

Permalink
fix(arborist): make sure resolveParent exists before checking props
Browse files Browse the repository at this point in the history
  • Loading branch information
nlf authored and lukekarrys committed Mar 28, 2022
1 parent 6f9cb49 commit 18b8b94
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
2 changes: 1 addition & 1 deletion workspaces/arborist/lib/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -1308,7 +1308,7 @@ module.exports = cls => class Reifier extends cls {
// to only names that are found in this list
const retrieveUpdatedNodes = names => {
const filterDirectDependencies = node =>
!node.isRoot && node.resolveParent.isRoot
!node.isRoot && node.resolveParent && node.resolveParent.isRoot
&& (!names || names.includes(node.name))
&& exactVersion(node) // skip update for exact ranges

Expand Down
28 changes: 28 additions & 0 deletions workspaces/arborist/test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -2622,5 +2622,33 @@ t.test('save package.json on update', t => {
'should save no top level dep update to root package.json'
)
})

t.test('should not throw when trying to update a link dep', async t => {
const path = t.testdir({
one: {
'package.json': JSON.stringify({
name: 'one',
version: '1.0.0',
dependencies: {
two: 'file:../two',
},
}),
},
two: {
'package.json': JSON.stringify({
name: 'two',
version: '1.0.0',
}),
},
})

await t.resolves(reify(resolve(path, 'one'), { update: true, save: true, workspaces: [] }))

t.equal(
require(resolve(path, 'one', 'package.json')).dependencies.two,
'file:../two',
'should have made no changes'
)
})
t.end()
})

0 comments on commit 18b8b94

Please sign in to comment.