diff --git a/lib/commands/outdated.js b/lib/commands/outdated.js index 714b3ab64da4d..7ecb0abade64a 100644 --- a/lib/commands/outdated.js +++ b/lib/commands/outdated.js @@ -177,6 +177,11 @@ class Outdated extends ArboristWorkspaceCmd { return } + // local workspaces are never fetched from the registry + if (edge.to?.isWorkspace) { + return + } + // if it's not a range, version, or tag, skip it if (!safeNpa(`${edge.name}@${edge.spec}`)?.registry) { return null diff --git a/test/lib/commands/outdated.js b/test/lib/commands/outdated.js index 34b8ea75190fc..b2dea4860e5e6 100644 --- a/test/lib/commands/outdated.js +++ b/test/lib/commands/outdated.js @@ -57,6 +57,11 @@ const packument = spec => { }, }, }, + unpublished: { + name: 'unpublished', + 'dist-tags': {}, + versions: {}, + }, timed: { name: 'timed', 'dist-tags': { @@ -620,6 +625,43 @@ t.test('workspaces', async t => { await t.test('should display missing deps when filtering by ws', t => mockWorkspaces(t, { workspace: 'c', exitCode: 1 })) + + await t.test('should ignore ws dep sharing a name with an unpublished package', async t => { + const testDir = { + 'package.json': JSON.stringify({ + name: 'workspaces-project', + version: '1.0.0', + workspaces: ['packages/*'], + }), + node_modules: { + a: t.fixture('symlink', '../packages/a'), + unpublished: t.fixture('symlink', '../packages/unpublished'), + }, + packages: { + a: { + 'package.json': JSON.stringify({ + name: 'a', + version: '1.0.0', + dependencies: { + unpublished: '^1.0.0', + }, + }), + }, + unpublished: { + 'package.json': JSON.stringify({ + name: 'unpublished', + version: '1.0.0', + }), + }, + }, + } + + const { outdated, joinedOutput } = await mockNpm(t, { + prefixDir: testDir, + }) + await outdated.exec([]) + t.equal(joinedOutput(), '', 'no logs') + }) }) t.test('aliases', async t => {