Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions workspaces/arborist/lib/arborist/isolated-reifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ module.exports = cls => class IsolatedReifier extends cls {
}
root.inventory.set('', root)
root.root = root
root.top = root
root.target = root
// TODO inventory.query is a stub; audit-report needs 'packageName' support
root.inventory.query = () => {
Expand All @@ -335,6 +336,7 @@ module.exports = cls => class IsolatedReifier extends cls {
hasInstallScript: c.hasInstallScript,
isLink: false,
isRoot: false,
isWorkspace: true,
linksIn: new Set(),
location: c.localLocation,
name: wsName,
Expand All @@ -344,6 +346,7 @@ module.exports = cls => class IsolatedReifier extends cls {
resolved: c.resolved,
}
workspace.target = workspace
workspace.top = workspace
root.fsChildren.add(workspace)
root.inventory.set(workspace.location, workspace)

Expand All @@ -369,6 +372,7 @@ module.exports = cls => class IsolatedReifier extends cls {
realpath: workspace.path,
root,
target: workspace,
top: root,
}
root.children.set(wsLink.name, wsLink)
root.inventory.set(wsLink.location, wsLink)
Expand Down
47 changes: 47 additions & 0 deletions workspaces/arborist/test/arborist/reify.js
Original file line number Diff line number Diff line change
Expand Up @@ -3250,4 +3250,51 @@ t.test('install stategy linked', async (t) => {
t.ok(store.isDirectory(), 'abbrev got installed')
t.ok(abbrev.isSymbolicLink(), 'abbrev got installed')
})

t.test('should not crash with --omit=dev in workspaces', async (t) => {
const testdir = t.testdir({
project: {
'package.json': JSON.stringify({
name: 'my-monorepo',
version: '1.0.0',
workspaces: ['packages/*'],
dependencies: {
abbrev: '1.1.1',
},
devDependencies: {
abbrev: '1.1.1',
},
}),
packages: {
'my-lib': {
'package.json': JSON.stringify({
name: 'my-lib',
version: '1.0.0',
dependencies: {
abbrev: '1.1.1',
},
}),
},
},
},
})

tnock(t, 'https://registry.npmjs.org')
.get('/abbrev')
.reply(200, abbrevPackument)

tnock(t, 'https://registry.npmjs.org')
.get('/abbrev/-/abbrev-1.1.1.tgz')
.reply(200, abbrevTGZ)

const path = resolve(testdir, 'project')
const arb = new Arborist({
path,
registry: 'https://registry.npmjs.org',
cache: resolve(testdir, 'cache'),
installStrategy: 'linked',
})
await arb.reify({ installStrategy: 'linked', omit: ['dev'] })
t.pass('reify with --omit=dev did not crash')
})
})
Loading