node/deps/npm/lib/commands/bugs.js
npm-cli+bot@github.com 06dd8c31fd deps: upgrade npm to 8.10.0
PR-URL: https://github.com/nodejs/node/pull/43061
Reviewed-By: Ruy Adorno <ruyadorno@github.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
2022-05-18 19:13:24 +02:00

34 lines
815 B
JavaScript

const PackageUrlCmd = require('../package-url-cmd.js')
class Bugs extends PackageUrlCmd {
static description = 'Report bugs for a package in a web browser'
static name = 'bugs'
getUrl (spec, mani) {
if (mani.bugs) {
if (typeof mani.bugs === 'string') {
return mani.bugs
}
if (typeof mani.bugs === 'object' && mani.bugs.url) {
return mani.bugs.url
}
if (typeof mani.bugs === 'object' && mani.bugs.email) {
return `mailto:${mani.bugs.email}`
}
}
// try to get it from the repo, if possible
const info = this.hostedFromMani(mani)
if (info) {
return info.bugs()
}
// just send them to the website, hopefully that has some info!
return `https://www.npmjs.com/package/${mani.name}`
}
}
module.exports = Bugs