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

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/npm-registry-client/lib/unpublish.js')
-rw-r--r--node_modules/npm-registry-client/lib/unpublish.js32
1 files changed, 16 insertions, 16 deletions
diff --git a/node_modules/npm-registry-client/lib/unpublish.js b/node_modules/npm-registry-client/lib/unpublish.js
index 1887a99e6..fc2e3b559 100644
--- a/node_modules/npm-registry-client/lib/unpublish.js
+++ b/node_modules/npm-registry-client/lib/unpublish.js
@@ -11,19 +11,18 @@ var semver = require("semver")
, url = require("url")
, chain = require("slide").chain
-function unpublish (name, ver, cb) {
+function unpublish (uri, ver, cb) {
if (typeof cb !== "function") cb = ver, ver = null
- var u = name + '?write=true'
- this.get(u, null, -1, true, function (er, data) {
+ this.get(uri + "?write=true", { timeout : -1, follow : false }, function (er, data) {
if (er) {
- this.log.info("unpublish", name+" not published")
+ this.log.info("unpublish", uri+" not published")
return cb()
}
// remove all if no version specified
if (!ver) {
this.log.info("unpublish", "No version specified, removing all")
- return this.request("DELETE", name+'/-rev/'+data._rev, cb)
+ return this.request("DELETE", uri+'/-rev/'+data._rev, cb)
}
var versions = data.versions || {}
@@ -31,7 +30,7 @@ function unpublish (name, ver, cb) {
var dist
if (!versionPublic) {
- this.log.info("unpublish", name+"@"+ver+" not published")
+ this.log.info("unpublish", uri+"@"+ver+" not published")
} else {
dist = versions[ver].dist
this.log.verbose("unpublish", "removing attachments", dist)
@@ -41,7 +40,7 @@ function unpublish (name, ver, cb) {
// if it was the only version, then delete the whole package.
if (!Object.keys(versions).length) {
this.log.info("unpublish", "No versions remain, removing entire package")
- return this.request("DELETE", name+"/-rev/"+data._rev, cb)
+ return this.request("DELETE", uri + "/-rev/" + data._rev, null, cb)
}
if (!versionPublic) return cb()
@@ -59,8 +58,9 @@ function unpublish (name, ver, cb) {
var rev = data._rev
delete data._revisions
delete data._attachments
- var cb_ = detacher.call(this, data, dist, cb)
- this.request("PUT", name+"/-rev/"+rev, data, function (er) {
+ var cb_ = detacher.call(this, uri, data, dist, cb)
+
+ this.request("PUT", uri + "/-rev/" + rev, { body : data }, function (er) {
if (er) {
this.log.error("unpublish", "Failed to update data")
}
@@ -69,20 +69,20 @@ function unpublish (name, ver, cb) {
}.bind(this))
}
-function detacher (data, dist, cb) {
+function detacher (uri, data, dist, cb) {
return function (er) {
if (er) return cb(er)
- this.get(data.name, function (er, data) {
+ this.get(url.resolve(uri, data.name), null, function (er, data) {
if (er) return cb(er)
var tb = url.parse(dist.tarball)
- detach.call(this, data, tb.pathname, data._rev, function (er) {
+ detach.call(this, uri, data, tb.pathname, data._rev, function (er) {
if (er || !dist.bin) return cb(er)
chain(Object.keys(dist.bin).map(function (bt) {
return function (cb) {
var d = dist.bin[bt]
- detach.call(this, data, url.parse(d.tarball).pathname, null, cb)
+ detach.call(this, uri, data, url.parse(d.tarball).pathname, null, cb)
}.bind(this)
}, this), cb)
}.bind(this))
@@ -90,13 +90,13 @@ function detacher (data, dist, cb) {
}.bind(this)
}
-function detach (data, path, rev, cb) {
+function detach (uri, data, path, rev, cb) {
if (rev) {
path += "/-rev/" + rev
this.log.info("detach", path)
- return this.request("DELETE", path, cb)
+ return this.request("DELETE", url.resolve(uri, path), null, cb)
}
- this.get(data.name, function (er, data) {
+ this.get(url.resolve(uri, data.name), null, function (er, data) {
rev = data._rev
if (!rev) return cb(new Error(
"No _rev found in "+data._id))