diff --git a/lib/commands/bugs.js b/lib/commands/bugs.js index 17cbd96649b87..44926afbc9a0a 100644 --- a/lib/commands/bugs.js +++ b/lib/commands/bugs.js @@ -21,8 +21,9 @@ class Bugs extends PackageUrlCmd { // try to get it from the repo, if possible const info = this.hostedFromMani(mani) - if (info) { - return info.bugs() + const infoUrl = info?.bugs() + if (infoUrl) { + return infoUrl } // just send them to the website, hopefully that has some info! diff --git a/test/lib/commands/bugs.js b/test/lib/commands/bugs.js index 953c8e6345a2a..e2ebfb5306574 100644 --- a/test/lib/commands/bugs.js +++ b/test/lib/commands/bugs.js @@ -6,6 +6,10 @@ const pacote = { return spec === 'nobugs' ? { name: 'nobugs', version: '1.2.3', + } : spec === 'nullbugs' ? { + name: 'nullbugs', + version: '1.2.3', + bugs: null, } : spec === 'bugsurl' ? { name: 'bugsurl', version: '1.2.3', @@ -66,6 +70,7 @@ t.test('open bugs urls & emails', async t => { const expected = { '.': 'https://example.com', nobugs: 'https://www.npmjs.com/package/nobugs', + nullbugs: 'https://www.npmjs.com/package/nullbugs', 'bugsobj-nourl': 'https://www.npmjs.com/package/bugsobj-nourl', bugsurl: 'https://bugzilla.localhost/bugsurl', bugsobj: 'https://bugzilla.localhost/bugsobj',