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

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/npm-registry-client/lib/upload.js')
-rw-r--r--deps/npm/node_modules/npm-registry-client/lib/upload.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/deps/npm/node_modules/npm-registry-client/lib/upload.js b/deps/npm/node_modules/npm-registry-client/lib/upload.js
new file mode 100644
index 00000000000..2418997b441
--- /dev/null
+++ b/deps/npm/node_modules/npm-registry-client/lib/upload.js
@@ -0,0 +1,22 @@
+module.exports = upload
+
+var fs = require('fs')
+, Stream = require("stream").Stream
+
+function upload (where, file, etag, nofollow, cb) {
+ if (typeof nofollow === "function") cb = nofollow, nofollow = false
+ if (typeof etag === "function") cb = etag, etag = null
+
+ if (file instanceof Stream) {
+ return this.request("PUT", where, file, etag, nofollow, cb)
+ }
+
+ fs.stat(file, function (er, stat) {
+ if (er) return cb(er)
+ var s = fs.createReadStream(file)
+ s.size = stat.size
+ s.on("error", cb)
+
+ this.request("PUT", where, s, etag, nofollow, cb)
+ }.bind(this))
+}