1 var npm = require("./npm.js")
2 , mapToRegistry = require("./utils/map-to-registry.js")
3 , npa = require("npm-package-arg")
5 module.exports = deprecate
7 deprecate.usage = "npm deprecate <pkg>[@<version>] <message>"
9 deprecate.completion = function (opts, cb) {
10 // first, get a list of remote packages this user owns.
11 // once we have a user account, then don't complete anything.
12 if (opts.conf.argv.remain.length > 2) return cb()
13 // get the list of packages by user
14 var path = "/-/by-user/"
15 mapToRegistry(path, npm.config, function (er, uri, c) {
18 if (!(c && c.username)) return cb()
24 npm.registry.get(uri + c.username, params, function (er, list) {
27 return cb(null, list[c.username])
32 function deprecate (args, cb) {
35 if (msg === undefined) return cb("Usage: " + deprecate.usage)
37 // fetch the data and make sure it exists.
40 // npa makes the default spec "latest", but for deprecation
41 // "*" is the appropriate default.
42 if (p.rawSpec === '') p.spec = '*'
44 mapToRegistry(p.name, npm.config, function (er, uri, auth) {
52 npm.registry.deprecate(uri, params, cb)