]> gerrit.simantics Code Review - simantics/district.git/blob - org.simantics.maps.server/node/node-v4.8.0-win-x64/node_modules/npm/lib/deprecate.js
Adding integrated tile server
[simantics/district.git] / org.simantics.maps.server / node / node-v4.8.0-win-x64 / node_modules / npm / lib / deprecate.js
1 var npm = require("./npm.js")
2   , mapToRegistry = require("./utils/map-to-registry.js")
3   , npa = require("npm-package-arg")
4
5 module.exports = deprecate
6
7 deprecate.usage = "npm deprecate <pkg>[@<version>] <message>"
8
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) {
16     if (er) return cb(er)
17
18     if (!(c && c.username)) return cb()
19
20     var params = {
21       timeout : 60000,
22       auth    : c
23     }
24     npm.registry.get(uri + c.username, params, function (er, list) {
25       if (er) return cb()
26       console.error(list)
27       return cb(null, list[c.username])
28     })
29   })
30 }
31
32 function deprecate (args, cb) {
33   var pkg = args[0]
34     , msg = args[1]
35   if (msg === undefined) return cb("Usage: " + deprecate.usage)
36
37   // fetch the data and make sure it exists.
38   var p = npa(pkg)
39
40   // npa makes the default spec "latest", but for deprecation
41   // "*" is the appropriate default.
42   if (p.rawSpec === '') p.spec = '*'
43
44   mapToRegistry(p.name, npm.config, function (er, uri, auth) {
45     if (er) return cb(er)
46
47     var params = {
48       version : p.spec,
49       message : msg,
50       auth    : auth
51     }
52     npm.registry.deprecate(uri, params, cb)
53   })
54 }