Comparing version 1.0.0 to 1.0.1
@@ -1,4 +0,5 @@ | ||
var when = require("when"), | ||
nodefn = require("when/node"), | ||
model = require("./model"); | ||
var when = require("when"), | ||
nodefn = require("when/node"), | ||
semaphore = require("semaphore"), | ||
model = require("./model"); | ||
@@ -45,20 +46,25 @@ if (typeof(require) !== 'undefined') { | ||
var self = this; | ||
var sem = semaphore(20); | ||
var results = files.map(function(file) { | ||
return nodefn.call(fs.readFile, file.abs).then(function(data) { | ||
var filePath = file.rel.split("/").map(function(segment) { | ||
return encodeURIComponent(segment); | ||
}).join("/"); | ||
sem.take(function() { | ||
return nodefn.call(fs.readFile, file.abs).then(function(data) { | ||
var filePath = file.rel.split("/").map(function(segment) { | ||
return encodeURIComponent(segment); | ||
}).join("/"); | ||
return self.client.request({ | ||
url: "/deploys/" + self.id + "/files/" + filePath, | ||
type: "put", | ||
body: data, | ||
contentType: "application/octet-stream", | ||
ignoreResponse: true | ||
}).then(function(response) { | ||
progress && progress("upload", {file: file, total: files.length}); | ||
return file; | ||
}).catch(function(response) { | ||
progress && progress("uploadError", {file:file, message: response.data}); | ||
return when.reject(response.data); | ||
return self.client.request({ | ||
url: "/deploys/" + self.id + "/files/" + filePath, | ||
type: "put", | ||
body: data, | ||
contentType: "application/octet-stream", | ||
ignoreResponse: true | ||
}).then(function(response) { | ||
progress && progress("upload", {file: file, total: files.length}); | ||
sem.leave(); | ||
return file; | ||
}).catch(function(response) { | ||
progress && progress("uploadError", {file:file, message: response.data}); | ||
sem.leave(); | ||
return when.reject(response.data); | ||
}); | ||
}); | ||
@@ -65,0 +71,0 @@ }); |
@@ -5,3 +5,3 @@ { | ||
"description": "Netlify API client", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"bugs": { | ||
@@ -20,2 +20,3 @@ "url": "https://github.com/netlify/netlify-js/issues" | ||
"graceful-fs": "^3.0.4", | ||
"semaphore": "^1.0.5", | ||
"when": "^3.7.5" | ||
@@ -22,0 +23,0 @@ }, |
770959
4956
5
+ Addedsemaphore@^1.0.5
+ Addedsemaphore@1.1.0(transitive)