diff options
author | nlf <quitlahok@gmail.com> | 2022-03-24 23:52:50 +0300 |
---|---|---|
committer | Luke Karrys <luke@lukekarrys.com> | 2022-03-28 23:19:59 +0300 |
commit | 18b8b94357d8f57301fbaa0f1e5dc2cf1128bf3e (patch) | |
tree | ac48ea68fcd9b5611e1a6e475bc431bb5ac39b63 /workspaces | |
parent | 6f9cb490e7299976c43c6a118036c130671fe188 (diff) |
fix(arborist): make sure resolveParent exists before checking props
Diffstat (limited to 'workspaces')
-rw-r--r-- | workspaces/arborist/lib/arborist/reify.js | 2 | ||||
-rw-r--r-- | workspaces/arborist/test/arborist/reify.js | 28 |
2 files changed, 29 insertions, 1 deletions
diff --git a/workspaces/arborist/lib/arborist/reify.js b/workspaces/arborist/lib/arborist/reify.js index acb889ceb..7fd0ca7f6 100644 --- a/workspaces/arborist/lib/arborist/reify.js +++ b/workspaces/arborist/lib/arborist/reify.js @@ -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 diff --git a/workspaces/arborist/test/arborist/reify.js b/workspaces/arborist/test/arborist/reify.js index 7c22f7c69..9124b4630 100644 --- a/workspaces/arborist/test/arborist/reify.js +++ b/workspaces/arborist/test/arborist/reify.js @@ -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() }) |