diff options
author | isaacs <i@izs.me> | 2013-03-06 15:41:06 -0800 |
---|---|---|
committer | isaacs <i@izs.me> | 2013-03-06 15:41:06 -0800 |
commit | 80fb580936d82bb274bd35fe66e7d61cc01b0fd4 (patch) | |
tree | 5354e1c4b46a349c654e2b9008eac424ceeb232d /deps/npm/node_modules/npm-registry-client/lib/publish.js | |
parent | 277a2545d2615420240f9b6f0e866ce1cde66890 (diff) | |
download | android-node-v8-80fb580936d82bb274bd35fe66e7d61cc01b0fd4.tar.gz android-node-v8-80fb580936d82bb274bd35fe66e7d61cc01b0fd4.tar.bz2 android-node-v8-80fb580936d82bb274bd35fe66e7d61cc01b0fd4.zip |
npm: Update to 1.2.14
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/lib/publish.js')
-rw-r--r-- | deps/npm/node_modules/npm-registry-client/lib/publish.js | 42 |
1 files changed, 19 insertions, 23 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/lib/publish.js b/deps/npm/node_modules/npm-registry-client/lib/publish.js index b44b801b3a..d6a7496f1f 100644 --- a/deps/npm/node_modules/npm-registry-client/lib/publish.js +++ b/deps/npm/node_modules/npm-registry-client/lib/publish.js @@ -72,22 +72,23 @@ function publish (data, tarball, cb) { this.request("GET", data.name, function (er, fullData) { if (er) return cb(er) + function handle(er) { + if (er.message.indexOf("conflict Document update conflict.") === 0) { + return cb(conflictError.call(this, data._id)); + } + this.log.error("publish", "Error uploading package"); + return cb(er) + } + var exists = fullData.versions && fullData.versions[data.version] if (exists) return cb(conflictError.call(this, data._id)) - this.request("PUT", dataURI, data, function (er) { - if (er) { - if (er.message.indexOf("conflict Document update conflict.") === 0) { - return cb(conflictError.call(this, data._id)) - } - this.log.error("publish", "Error sending version data") - return cb(er) - } - - this.log.verbose("publish", "attach 2", [data.name, tarball, tbName]) - attach.call(this, data.name, tarball, tbName, function (er) { - this.log.verbose("publish", "attach 3" - ,[er, data.name]) + var rev = fullData._rev; + attach.call(this, data.name, tarball, tbName, rev, function (er) { + if (er) return handle.call(this, er) + this.log.verbose("publish", "attached", [data.name, tarball, tbName]) + this.request("PUT", dataURI, data, function (er) { + if (er) return handle.call(this, er) return cb(er) }.bind(this)) }.bind(this)) @@ -102,15 +103,10 @@ function conflictError (pkgid) { return e } -function attach (doc, file, filename, cb) { +function attach (doc, file, filename, rev, cb) { doc = encodeURIComponent(doc) - this.request("GET", doc, function (er, d) { - if (er) return cb(er) - if (!d) return cb(new Error( - "Attempting to upload to invalid doc "+doc)) - var rev = "-rev/"+d._rev - , attURI = doc + "/-/" + encodeURIComponent(filename) + "/" + rev - this.log.verbose("uploading", [attURI, file]) - this.upload(attURI, file, cb) - }.bind(this)) + var revu = "-rev/"+rev + , attURI = doc + "/-/" + encodeURIComponent(filename) + "/" + revu + this.log.verbose("uploading", [attURI, file]) + this.upload(attURI, file, cb) } |