From 52ec5ec61fd3b266efd7a9c5712dd6a769a2d365 Mon Sep 17 00:00:00 2001 From: Gar Date: Tue, 12 Jul 2022 10:14:38 -0700 Subject: [PATCH] fix: properly open package arg repo inside workspace (#5154) --- lib/package-url-cmd.js | 3 +++ test/lib/commands/repo.js | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/package-url-cmd.js b/lib/package-url-cmd.js index b897272149d02..4254dde4517ba 100644 --- a/lib/package-url-cmd.js +++ b/lib/package-url-cmd.js @@ -40,6 +40,9 @@ class PackageUrlCommand extends BaseCommand { } async execWorkspaces (args, filters) { + if (args && args.length) { + return this.exec(args) + } await this.setWorkspaces(filters) return this.exec(this.workspacePaths) } diff --git a/test/lib/commands/repo.js b/test/lib/commands/repo.js index e06a2894417bc..4c983f1353f00 100644 --- a/test/lib/commands/repo.js +++ b/test/lib/commands/repo.js @@ -311,4 +311,12 @@ t.test('workspaces', async t => { ) t.match({}, opened, 'opened no repo urls') }) + + t.test('package arg and workspace', async (t) => { + npm.config.set('workspace', ['workspace-a']) + await npm.exec('repo', ['.']) + t.match({ + 'https://github.com/npm/workspaces-test': 1, + }, opened, 'opened url for package arg, not workspace') + }) })