Skip to content

Commit 2d83231

Browse files
fix(arborist): add missing top property to isolated reifier proxy nodes (#9064)
1 parent 64e142a commit 2d83231

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

workspaces/arborist/lib/arborist/isolated-reifier.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ module.exports = cls => class IsolatedReifier extends cls {
318318
}
319319
root.inventory.set('', root)
320320
root.root = root
321+
root.top = root
321322
root.target = root
322323
// TODO inventory.query is a stub; audit-report needs 'packageName' support
323324
root.inventory.query = () => {
@@ -335,6 +336,7 @@ module.exports = cls => class IsolatedReifier extends cls {
335336
hasInstallScript: c.hasInstallScript,
336337
isLink: false,
337338
isRoot: false,
339+
isWorkspace: true,
338340
linksIn: new Set(),
339341
location: c.localLocation,
340342
name: wsName,
@@ -344,6 +346,7 @@ module.exports = cls => class IsolatedReifier extends cls {
344346
resolved: c.resolved,
345347
}
346348
workspace.target = workspace
349+
workspace.top = workspace
347350
root.fsChildren.add(workspace)
348351
root.inventory.set(workspace.location, workspace)
349352

@@ -369,6 +372,7 @@ module.exports = cls => class IsolatedReifier extends cls {
369372
realpath: workspace.path,
370373
root,
371374
target: workspace,
375+
top: root,
372376
}
373377
root.children.set(wsLink.name, wsLink)
374378
root.inventory.set(wsLink.location, wsLink)

workspaces/arborist/test/arborist/reify.js

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3250,4 +3250,51 @@ t.test('install stategy linked', async (t) => {
32503250
t.ok(store.isDirectory(), 'abbrev got installed')
32513251
t.ok(abbrev.isSymbolicLink(), 'abbrev got installed')
32523252
})
3253+
3254+
t.test('should not crash with --omit=dev in workspaces', async (t) => {
3255+
const testdir = t.testdir({
3256+
project: {
3257+
'package.json': JSON.stringify({
3258+
name: 'my-monorepo',
3259+
version: '1.0.0',
3260+
workspaces: ['packages/*'],
3261+
dependencies: {
3262+
abbrev: '1.1.1',
3263+
},
3264+
devDependencies: {
3265+
abbrev: '1.1.1',
3266+
},
3267+
}),
3268+
packages: {
3269+
'my-lib': {
3270+
'package.json': JSON.stringify({
3271+
name: 'my-lib',
3272+
version: '1.0.0',
3273+
dependencies: {
3274+
abbrev: '1.1.1',
3275+
},
3276+
}),
3277+
},
3278+
},
3279+
},
3280+
})
3281+
3282+
tnock(t, 'https://registry.npmjs.org')
3283+
.get('/abbrev')
3284+
.reply(200, abbrevPackument)
3285+
3286+
tnock(t, 'https://registry.npmjs.org')
3287+
.get('/abbrev/-/abbrev-1.1.1.tgz')
3288+
.reply(200, abbrevTGZ)
3289+
3290+
const path = resolve(testdir, 'project')
3291+
const arb = new Arborist({
3292+
path,
3293+
registry: 'https://registry.npmjs.org',
3294+
cache: resolve(testdir, 'cache'),
3295+
installStrategy: 'linked',
3296+
})
3297+
await arb.reify({ installStrategy: 'linked', omit: ['dev'] })
3298+
t.pass('reify with --omit=dev did not crash')
3299+
})
32533300
})

0 commit comments

Comments
 (0)