Skip to content

Commit 834e62a

Browse files
committed
fix: npm ls extraneous workspaces
1 parent 5345f03 commit 834e62a

7 files changed

Lines changed: 80 additions & 21 deletions

File tree

node_modules/@npmcli/arborist/lib/arborist/build-ideal-tree.js

Lines changed: 0 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@npmcli/arborist/lib/arborist/load-actual.js

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

node_modules/@npmcli/arborist/package.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"./package.json": "./package.json"
4343
},
4444
"dependencies": {
45-
"@npmcli/arborist": "^0.0.17",
45+
"@npmcli/arborist": "^0.0.19",
4646
"@npmcli/ci-detect": "^1.2.0",
4747
"@npmcli/run-script": "^1.5.0",
4848
"abbrev": "~1.1.1",

tap-snapshots/test-lib-ls.js-TAP.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -424,6 +424,19 @@ exports[`test/lib/ls.js TAP ls json read problems > should print empty result 1`
424424
425425
`
426426

427+
exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should filter single workspace 1`] = `
428+
[email protected] {CWD}/ls-ls-loading-a-tree-containing-workspaces
429+
\`-- [email protected] -> {CWD}/ls-ls-loading-a-tree-containing-workspaces/a
430+
431+
`
432+
433+
exports[`test/lib/ls.js TAP ls loading a tree containing workspaces > should list workspaces properly 1`] = `
434+
[email protected] {CWD}/ls-ls-loading-a-tree-containing-workspaces
435+
+-- [email protected] -> {CWD}/ls-ls-loading-a-tree-containing-workspaces/a
436+
\`-- [email protected] -> {CWD}/ls-ls-loading-a-tree-containing-workspaces/b
437+
438+
`
439+
427440
exports[`test/lib/ls.js TAP ls missing package.json > should log all extraneous deps on error msg 1`] = `
428441
extraneous: [email protected] {CWD}/ls-ls-missing-package-json/node_modules/bar
429442
extraneous: [email protected] {CWD}/ls-ls-missing-package-json/node_modules/foo

test/lib/ls.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,48 @@ t.test('ls', (t) => {
13841384
})
13851385
})
13861386

1387+
t.test('loading a tree containing workspaces', (t) => {
1388+
prefix = t.testdir({
1389+
'package.json': JSON.stringify({
1390+
name: 'filter-by-child-of-missing-dep',
1391+
version: '1.0.0',
1392+
workspaces: [
1393+
'./a',
1394+
'./b'
1395+
]
1396+
}),
1397+
node_modules: {
1398+
a: t.fixture('symlink', '../a'),
1399+
b: t.fixture('symlink', '../b')
1400+
},
1401+
a: {
1402+
'package.json': JSON.stringify({
1403+
name: 'a',
1404+
version: '1.0.0'
1405+
})
1406+
},
1407+
b: {
1408+
'package.json': JSON.stringify({
1409+
name: 'b',
1410+
version: '1.0.0'
1411+
})
1412+
}
1413+
})
1414+
1415+
ls([], (err) => {
1416+
t.ifError(err, 'should NOT have ELSPROBLEMS error code')
1417+
t.matchSnapshot(redactCwd(result), 'should list workspaces properly')
1418+
1419+
// should also be able to filter out one of the workspaces
1420+
ls(['a'], (err) => {
1421+
t.ifError(err, 'should NOT have ELSPROBLEMS error code when filter')
1422+
t.matchSnapshot(redactCwd(result), 'should filter single workspace')
1423+
1424+
t.end()
1425+
})
1426+
})
1427+
})
1428+
13871429
t.end()
13881430
})
13891431

0 commit comments

Comments
 (0)