Skip to content
Open
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
1 change: 1 addition & 0 deletions lib/commands/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class LS extends ArboristWorkspaceCmd {
const filterBySelectedWorkspaces = edge => {
if (!workspacesEnabled
&& edge.from.isProjectRoot
&& edge.to
&& edge.to.isWorkspace
) {
return false
Expand Down
6 changes: 6 additions & 0 deletions tap-snapshots/test/lib/commands/ls.js.test.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,12 @@ test-npm-ls@1.0.0 {CWD}/prefix
\`-- dog@1.0.0
`

exports[`test/lib/commands/ls.js TAP ls no workspaces and missing optional dep > should list missing optional dep and omit workspaces 1`] = `
root@ {CWD}/prefix
+-- UNMET OPTIONAL DEPENDENCY bar@^1.0.0
\`-- foo@1.0.0
`

exports[`test/lib/commands/ls.js TAP ls overridden dep > should contain overridden output 1`] = `
test-overridden@1.0.0 {CWD}/prefix
\`-- foo@1.0.0
Expand Down
39 changes: 39 additions & 0 deletions test/lib/commands/ls.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,45 @@ t.test('ls', async t => {
t.matchSnapshot(cleanCwd(result()), 'should omit missing optional dep')
})

t.test('no workspaces and missing optional dep', async t => {
const config = {
workspaces: false,
}
const { result, ls } = await mockLs(t, {
config,
prefixDir: {
'package.json': JSON.stringify({
name: 'root',
dependencies: {
foo: '^1.0.0',
},
optionalDependencies: {
bar: '^1.0.0',
},
workspaces: ['./baz'],
}),
baz: {
'package.json': JSON.stringify({
name: 'baz',
version: '1.0.0',
}),
},
node_modules: {
baz: t.fixture('symlink', '../baz'),
foo: {
'package.json': JSON.stringify({
name: 'foo',
version: '1.0.0',
}),
},
},
},
})

await ls.exec([])
t.matchSnapshot(cleanCwd(result()), 'should list missing optional dep and omit workspaces')
})

t.test('extraneous deps', async t => {
const { result, ls } = await mockLs(t, {
config: {},
Expand Down
Loading