Skip to content

Commit 8e0a731

Browse files
fix(arborist): skip linked actual tree diff in package-lock-only mode (#9108)
1 parent 8afa3bd commit 8e0a731

2 files changed

Lines changed: 27 additions & 3 deletions

File tree

workspaces/arborist/lib/arborist/reify.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,9 +117,11 @@ module.exports = cls => class Reifier extends cls {
117117
// of Node/Link trees
118118
log.warn('reify', 'The "linked" install strategy is EXPERIMENTAL and may contain bugs.')
119119
this.idealTree = await this.createIsolatedTree()
120-
this.#linkedActualForDiff = this.#buildLinkedActualForDiff(
121-
this.idealTree, this.actualTree
122-
)
120+
if (this.actualTree) {
121+
this.#linkedActualForDiff = this.#buildLinkedActualForDiff(
122+
this.idealTree, this.actualTree
123+
)
124+
}
123125
}
124126
await this[_diffTrees]()
125127
await this.#reifyPackages()

workspaces/arborist/test/arborist/reify.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,28 @@ t.test('packageLockOnly can add deps', async t => {
199199
t.throws(() => fs.statSync(path + '/node_modules'), { code: 'ENOENT' })
200200
})
201201

202+
t.test('packageLockOnly with linked strategy in workspaces', async t => {
203+
const path = t.testdir({
204+
'package.json': JSON.stringify({
205+
name: 'repro',
206+
private: true,
207+
workspaces: ['packages/*'],
208+
}),
209+
packages: {
210+
a: {
211+
'package.json': JSON.stringify({
212+
name: 'a',
213+
version: '1.0.0',
214+
}),
215+
},
216+
},
217+
})
218+
createRegistry(t, false)
219+
await reify(path, { packageLockOnly: true, installStrategy: 'linked' })
220+
t.ok(fs.existsSync(path + '/package-lock.json'), 'lock file created')
221+
t.throws(() => fs.statSync(path + '/node_modules'), { code: 'ENOENT' })
222+
})
223+
202224
t.test('malformed package.json should not be overwritten', async t => {
203225
t.plan(2)
204226

0 commit comments

Comments
 (0)