Welcome to mirror list, hosted at ThFree Co, Russian Federation.

add.js « dist-tags « lib « npm-registry-client « node_modules « npm « deps - github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 7443cbca2fe8e36fb9f8a4e9d4f5d9c18e9aaf21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
module.exports = add

var assert = require("assert")
var url = require("url")

var npa = require("npm-package-arg")

function add (uri, params, cb) {
  assert(typeof uri === "string", "must pass registry URI to distTags.add")
  assert(
    params && typeof params === "object",
    "must pass params to distTags.add"
  )
  assert(typeof cb === "function", "muss pass callback to distTags.add")

  assert(
    typeof params.package === "string",
    "must pass package name to distTags.add"
  )
  assert(
    typeof params.distTag === "string",
    "must pass package distTag name to distTags.add"
  )
  assert(
    typeof params.version === "string",
    "must pass version to be mapped to distTag to distTags.add"
  )
  assert(
    params.auth && typeof params.auth === "object",
    "must pass auth to distTags.add"
  )

  var p = npa(params.package)
  var package = p.scope ? params.package.replace("/", "%2f") : params.package
  var rest = "-/package/"+package+"/dist-tags/"+params.distTag

  var options = {
    method : "PUT",
    body : JSON.stringify(params.version),
    auth : params.auth
  }
  this.request(url.resolve(uri, rest), options, cb)
}