2022-05-11 17:17:18 +00:00
|
|
|
const PackageUrlCmd = require('../package-url-cmd.js')
|
2020-10-02 17:52:19 -04:00
|
|
|
|
2022-05-11 17:17:18 +00:00
|
|
|
class Bugs extends PackageUrlCmd {
|
2021-11-18 20:58:02 +00:00
|
|
|
static description = 'Report bugs for a package in a web browser'
|
|
|
|
static name = 'bugs'
|
2021-05-20 15:54:50 -04:00
|
|
|
|
2022-05-11 17:17:18 +00:00
|
|
|
getUrl (spec, mani) {
|
2021-03-04 17:40:28 -05:00
|
|
|
if (mani.bugs) {
|
2021-11-18 20:58:02 +00:00
|
|
|
if (typeof mani.bugs === 'string') {
|
2021-03-04 17:40:28 -05:00
|
|
|
return mani.bugs
|
2021-11-18 20:58:02 +00:00
|
|
|
}
|
2020-10-02 17:52:19 -04:00
|
|
|
|
2021-11-18 20:58:02 +00:00
|
|
|
if (typeof mani.bugs === 'object' && mani.bugs.url) {
|
2021-03-04 17:40:28 -05:00
|
|
|
return mani.bugs.url
|
2021-11-18 20:58:02 +00:00
|
|
|
}
|
2021-04-15 21:53:45 -04:00
|
|
|
|
2021-11-18 20:58:02 +00:00
|
|
|
if (typeof mani.bugs === 'object' && mani.bugs.email) {
|
2021-04-15 21:53:45 -04:00
|
|
|
return `mailto:${mani.bugs.email}`
|
2021-11-18 20:58:02 +00:00
|
|
|
}
|
2021-03-04 17:40:28 -05:00
|
|
|
}
|
2020-10-02 17:52:19 -04:00
|
|
|
|
2021-03-04 17:40:28 -05:00
|
|
|
// try to get it from the repo, if possible
|
2022-05-11 17:17:18 +00:00
|
|
|
const info = this.hostedFromMani(mani)
|
2023-10-13 06:55:37 -07:00
|
|
|
const infoUrl = info?.bugs()
|
|
|
|
if (infoUrl) {
|
|
|
|
return infoUrl
|
2021-11-18 20:58:02 +00:00
|
|
|
}
|
2021-03-04 17:40:28 -05:00
|
|
|
|
|
|
|
// just send them to the website, hopefully that has some info!
|
|
|
|
return `https://www.npmjs.com/package/${mani.name}`
|
|
|
|
}
|
2020-10-02 17:52:19 -04:00
|
|
|
}
|
|
|
|
|
2021-03-04 17:40:28 -05:00
|
|
|
module.exports = Bugs
|