2022-05-12 01:17:18 +08:00
|
|
|
const PackageUrlCmd = require('../package-url-cmd.js')
|
2024-05-01 14:53:22 +08:00
|
|
|
|
2022-05-12 01:17:18 +08:00
|
|
|
class Docs extends PackageUrlCmd {
|
2021-11-19 04:58:02 +08:00
|
|
|
static description = 'Open documentation for a package in a web browser'
|
|
|
|
static name = 'docs'
|
|
|
|
|
2022-05-12 01:17:18 +08:00
|
|
|
getUrl (spec, mani) {
|
2021-11-19 04:58:02 +08:00
|
|
|
if (mani.homepage) {
|
2021-03-05 06:40:28 +08:00
|
|
|
return mani.homepage
|
2021-11-19 04:58:02 +08:00
|
|
|
}
|
2021-03-05 06:40:28 +08:00
|
|
|
|
2022-05-12 01:17:18 +08:00
|
|
|
const info = this.hostedFromMani(mani)
|
2021-11-19 04:58:02 +08:00
|
|
|
if (info) {
|
2021-03-05 06:40:28 +08:00
|
|
|
return info.docs()
|
2021-11-19 04:58:02 +08:00
|
|
|
}
|
2021-03-05 06:40:28 +08:00
|
|
|
|
2022-05-12 01:17:18 +08:00
|
|
|
return `https://www.npmjs.com/package/${mani.name}`
|
2021-03-05 06:40:28 +08:00
|
|
|
}
|
2014-01-20 13:13:20 +08:00
|
|
|
}
|
2024-05-01 14:53:22 +08:00
|
|
|
|
2021-03-05 06:40:28 +08:00
|
|
|
module.exports = Docs
|