1module.exports = bugs 2 3var log = require('npmlog') 4var openUrl = require('./utils/open-url') 5var fetchPackageMetadata = require('./fetch-package-metadata.js') 6var usage = require('./utils/usage') 7 8bugs.usage = usage( 9 'bugs', 10 'npm bugs [<pkgname>]' 11) 12 13bugs.completion = function (opts, cb) { 14 // FIXME: there used to be registry completion here, but it stopped making 15 // sense somewhere around 50,000 packages on the registry 16 cb() 17} 18 19function bugs (args, cb) { 20 var n = args.length ? args[0] : '.' 21 fetchPackageMetadata(n, '.', {fullMetadata: true}, function (er, d) { 22 if (er) return cb(er) 23 24 var url = d.bugs && ((typeof d.bugs === 'string') ? d.bugs : d.bugs.url) 25 if (!url) { 26 url = 'https://www.npmjs.org/package/' + d.name 27 } 28 log.silly('bugs', 'url', url) 29 openUrl(url, 'bug list available at the following URL', cb) 30 }) 31} 32