Skip to content

Commit 18b8b94

Browse files
nlflukekarrys
authored andcommitted
fix(arborist): make sure resolveParent exists before checking props
1 parent 6f9cb49 commit 18b8b94

2 files changed

Lines changed: 29 additions & 1 deletion

File tree

workspaces/arborist/lib/arborist/reify.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,7 +1308,7 @@ module.exports = cls => class Reifier extends cls {
13081308
// to only names that are found in this list
13091309
const retrieveUpdatedNodes = names => {
13101310
const filterDirectDependencies = node =>
1311-
!node.isRoot && node.resolveParent.isRoot
1311+
!node.isRoot && node.resolveParent && node.resolveParent.isRoot
13121312
&& (!names || names.includes(node.name))
13131313
&& exactVersion(node) // skip update for exact ranges
13141314

workspaces/arborist/test/arborist/reify.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2622,5 +2622,33 @@ t.test('save package.json on update', t => {
26222622
'should save no top level dep update to root package.json'
26232623
)
26242624
})
2625+
2626+
t.test('should not throw when trying to update a link dep', async t => {
2627+
const path = t.testdir({
2628+
one: {
2629+
'package.json': JSON.stringify({
2630+
name: 'one',
2631+
version: '1.0.0',
2632+
dependencies: {
2633+
two: 'file:../two',
2634+
},
2635+
}),
2636+
},
2637+
two: {
2638+
'package.json': JSON.stringify({
2639+
name: 'two',
2640+
version: '1.0.0',
2641+
}),
2642+
},
2643+
})
2644+
2645+
await t.resolves(reify(resolve(path, 'one'), { update: true, save: true, workspaces: [] }))
2646+
2647+
t.equal(
2648+
require(resolve(path, 'one', 'package.json')).dependencies.two,
2649+
'file:../two',
2650+
'should have made no changes'
2651+
)
2652+
})
26252653
t.end()
26262654
})

0 commit comments

Comments
 (0)