Skip to content

Commit dab3033

Browse files
committed
fix(arborist): skip linked actual tree diff in package-lock-only mode (npm#9108)
1 parent 49a764e commit dab3033

2 files changed

Lines changed: 27 additions & 4 deletions

File tree

workspaces/arborist/lib/arborist/reify.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,11 @@ module.exports = cls => class Reifier extends cls {
139139
// of Node/Link trees
140140
log.warn('reify', 'The "linked" install strategy is EXPERIMENTAL and may contain bugs.')
141141
this.idealTree = await this.createIsolatedTree()
142-
this.#linkedActualForDiff = this.#buildLinkedActualForDiff(
143-
this.idealTree, this.actualTree
144-
)
142+
if (this.actualTree) {
143+
this.#linkedActualForDiff = this.#buildLinkedActualForDiff(
144+
this.idealTree, this.actualTree
145+
)
146+
}
145147
}
146148
await this[_diffTrees]()
147149
await this[_reifyPackages]()

workspaces/arborist/test/arborist/reify.js

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,28 @@ t.test('packageLockOnly can add deps', async t => {
186186
t.throws(() => fs.statSync(path + '/node_modules'), { code: 'ENOENT' })
187187
})
188188

189-
t.test('malformed package.json should not be overwitten', async t => {
189+
t.test('packageLockOnly with linked strategy in workspaces', async t => {
190+
const path = t.testdir({
191+
'package.json': JSON.stringify({
192+
name: 'repro',
193+
private: true,
194+
workspaces: ['packages/*'],
195+
}),
196+
packages: {
197+
a: {
198+
'package.json': JSON.stringify({
199+
name: 'a',
200+
version: '1.0.0',
201+
}),
202+
},
203+
},
204+
})
205+
await reify(path, { packageLockOnly: true, installStrategy: 'linked', registry })
206+
t.ok(fs.existsSync(path + '/package-lock.json'), 'lock file created')
207+
t.throws(() => fs.statSync(path + '/node_modules'), { code: 'ENOENT' })
208+
})
209+
210+
t.test('malformed package.json should not be overwritten', async t => {
190211
t.plan(2)
191212

192213
const path = fixture(t, 'malformed-json')

0 commit comments

Comments
 (0)