Comparing version 1.0.0 to 1.0.1
26
index.js
@@ -9,3 +9,4 @@ var through = require('through2'), | ||
config = {}, | ||
PLUGIN_NAME = 'gulp-blok'; | ||
PLUGIN_NAME = 'gulp-blok' | ||
queue = []; | ||
@@ -106,3 +107,8 @@ // Set up blok API information | ||
blok.upload = function (filepath, file, done) { | ||
if (queue.indexOf(filepath) > -1) { | ||
return; | ||
} | ||
queue.push(filepath); | ||
var key = blok._makeAssetKey(filepath, 'dist'), | ||
@@ -132,2 +138,5 @@ isBinary = isBinaryFile(filepath), | ||
function onUpdate(res) { | ||
var index = queue.indexOf(filepath); | ||
queue.splice(index, 1); | ||
if (res.error) { | ||
@@ -137,2 +146,3 @@ gutil.log(gutil.colors.red('Error uploading file ' + JSON.stringify(res.body))); | ||
gutil.log(gutil.colors.green('File "' + key + '" uploaded.')); | ||
done(); | ||
} | ||
@@ -151,5 +161,6 @@ } | ||
// queue files provided in the stream for deployment | ||
var apiBurstBucketSize = 40, | ||
uploadedFileCount = 0, | ||
stream; | ||
var apiBurstBucketSize = 40; | ||
var uploadedFileCount = 0; | ||
var stream; | ||
var uploadDone = function() {}; | ||
@@ -169,2 +180,5 @@ blok._setOptions(options); | ||
} | ||
if (options.hasOwnProperty('uploadDone')) { | ||
uploadDone = options['uploadDone']; | ||
} | ||
@@ -181,7 +195,7 @@ // creating a stream through which each file will pass | ||
if (uploadedFileCount <= apiBurstBucketSize) { | ||
blok.upload(file.path, file); | ||
blok.upload(file.path, file, uploadDone); | ||
} else { | ||
// Delay deployment based on position in the array to deploy 2 files per second | ||
// after hitting the initial burst bucket limit size | ||
setTimeout(blok.upload.bind(file.path, file), ((uploadedFileCount - apiBurstBucketSize) / 2) * 1000); | ||
setTimeout(blok.upload.bind(file.path, file), ((uploadedFileCount - apiBurstBucketSize) / 2) * 1000, uploadDone); | ||
} | ||
@@ -188,0 +202,0 @@ uploadedFileCount++; |
{ | ||
"name": "gulp-blok", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"description": "Tool to publish blok templates and assets", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5879
173