1const PackageUrlCmd = require('../package-url-cmd.js') 2 3class Bugs extends PackageUrlCmd { 4 static description = 'Report bugs for a package in a web browser' 5 static name = 'bugs' 6 7 getUrl (spec, mani) { 8 if (mani.bugs) { 9 if (typeof mani.bugs === 'string') { 10 return mani.bugs 11 } 12 13 if (typeof mani.bugs === 'object' && mani.bugs.url) { 14 return mani.bugs.url 15 } 16 17 if (typeof mani.bugs === 'object' && mani.bugs.email) { 18 return `mailto:${mani.bugs.email}` 19 } 20 } 21 22 // try to get it from the repo, if possible 23 const info = this.hostedFromMani(mani) 24 if (info) { 25 return info.bugs() 26 } 27 28 // just send them to the website, hopefully that has some info! 29 return `https://www.npmjs.com/package/${mani.name}` 30 } 31} 32 33module.exports = Bugs 34