diff options
author | nlf <quitlahok@gmail.com> | 2022-08-01 21:02:18 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-08-01 21:02:18 +0300 |
commit | eac1bf26f28e9e8fc07e1350c3d7b14a94005ebf (patch) | |
tree | 6bffad5b665a5830d2b3a1615972aab247c1fdf7 /test | |
parent | 58cc362ceec82ddeb16311d3fb574908294ac789 (diff) |
fix(ls): when filtering workspaces, make sure the edge has a to before checking if its a workspace (#5164)
Diffstat (limited to 'test')
-rw-r--r-- | test/lib/commands/ls.js | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/lib/commands/ls.js b/test/lib/commands/ls.js index 412d5ce65..f4cd4ef33 100644 --- a/test/lib/commands/ls.js +++ b/test/lib/commands/ls.js @@ -178,6 +178,44 @@ t.test('ls', t => { ) }) + t.test('workspace and missing optional dep', async t => { + npm.prefix = npm.localPrefix = t.testdir({ + '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', + }), + }, + }, + }) + + npm.flatOptions.includeWorkspaceRoot = true + t.teardown(() => { + delete npm.flatOptions.includeWorkspaceRoot + }) + + await ls.execWorkspaces([], ['baz']) + t.matchSnapshot(redactCwd(result), 'should omit missing optional dep') + }) + t.test('extraneous deps', async t => { npm.prefix = t.testdir({ 'package.json': JSON.stringify({ |