diff options
Diffstat (limited to 'lib/utils/npm-registry-client/unpublish.js')
-rw-r--r-- | lib/utils/npm-registry-client/unpublish.js | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/lib/utils/npm-registry-client/unpublish.js b/lib/utils/npm-registry-client/unpublish.js index 0c7c44991..4e4982c6b 100644 --- a/lib/utils/npm-registry-client/unpublish.js +++ b/lib/utils/npm-registry-client/unpublish.js @@ -8,7 +8,7 @@ module.exports = unpublish var request = require("./request.js") - , log = require("../log.js") + , log = require("npmlog") , get = require("./get.js") , semver = require("semver") , url = require("url") @@ -20,26 +20,29 @@ function unpublish (name, ver, cb) { "Not enough arguments for registry unpublish") get(name, null, -1, true, function (er, data) { - if (er) return log(name+" not published", "unpublish", cb) + if (er) { + log.info("unpublish", name+" not published") + return cb() + } // remove all if no version specified if (!ver) { - log("No version specified, removing all", "unpublish") + log.info("unpublish", "No version specified, removing all") return request("DELETE", name+'/-rev/'+data._rev, cb) } var versions = data.versions || {} , versionPublic = versions.hasOwnProperty(ver) - if (!versionPublic) log(name+"@"+ver+" not published", "unpublish") + if (!versionPublic) log.info("unpublish", name+"@"+ver+" not published") else { var dist = versions[ver].dist - log.verbose(dist, "removing attachments") + log.verbose("unpublish", "removing attachments", dist) } delete versions[ver] // if it was the only version, then delete the whole package. if (!Object.keys(versions).length) { - log("No versions remain, removing entire package", "unpublish") + log.info("unpublish", "No versions remain, removing entire package") return request("DELETE", name+"/-rev/"+data._rev, cb) } @@ -58,9 +61,13 @@ function unpublish (name, ver, cb) { var rev = data._rev delete data._revisions delete data._attachments - // log(data._rev, "rev") - request.PUT(name+"/-rev/"+rev, data, - log.er(detacher(data, dist, cb), "Failed to update the data")) + var cb_ = detacher(data, dist, cb) + request.PUT(name+"/-rev/"+rev, data, function (er) { + if (er) { + log.error("unpublish", "Failed to update data") + } + cb_(er) + }) }) } @@ -86,7 +93,7 @@ function detacher (data, dist, cb) { return function (er) { function detach (data, path, rev, cb) { if (rev) { path += "/-rev/" + rev - log(path, "detach") + log.info("detach", path) return request("DELETE", path, cb) } get(data.name, function (er, data) { |