gulp-s3-upload
Advanced tools
Comparing version 1.4.1 to 1.4.2
# Changelog | ||
## Version 1.4.2 | ||
* Update file-hashing function with [hasha](http://github.com/sindresorhus/hasha) from a signature change. Simply pull file buffer instead of promise for simplicity sake. | ||
* Remove old `console.log` from local dev. | ||
## Version 1.4.0, 1.4.1 | ||
@@ -4,0 +10,0 @@ |
108
index.js
@@ -33,3 +33,3 @@ var es = require('event-stream') | ||
var keyTransform, keyname, keyparts, filename, | ||
mimetype, mime_lookup_name, | ||
mimetype, mime_lookup_name, hash | ||
metadata = null, content_encoding = null | ||
@@ -152,79 +152,71 @@ ; | ||
hasha.fromFile(path.join(file.base, file.relative), | ||
{'algorithm': options.etag_hash}, function (hasha_err, hash) { | ||
hash = hasha(file._contents, {'algorithm': options.etag_hash}); | ||
if(hasha_err) { | ||
return callback(new gutil.PluginError(PLUGIN_NAME, "S3 hasha Error: " + err.stack)); | ||
} | ||
// *Note: `options.Metadata` is not filtered out later. | ||
// *Note: `options.Metadata` is not filtered out later. | ||
_s3.headObject({ | ||
'Bucket': the_bucket, | ||
'Key': keyname | ||
}, function (head_err, head_data) { | ||
_s3.headObject({ | ||
'Bucket': the_bucket, | ||
'Key': keyname | ||
}, function (head_err, head_data) { | ||
var objOpts; | ||
var objOpts; | ||
if(head_err && head_err.statusCode !== 404) { | ||
return callback(new gutil.PluginError(PLUGIN_NAME, "S3 headObject Error: " + head_err.stack)); | ||
} | ||
if(head_err && head_err.statusCode !== 404) { | ||
return callback(new gutil.PluginError(PLUGIN_NAME, "S3 headObject Error: " + head_err.stack)); | ||
} | ||
if(head_data && head_data.ETag === '"' + hash + '"') { | ||
if(head_data && head_data.ETag === '"' + hash + '"') { | ||
// AWS ETag doesn't match local ETag | ||
gutil.log(gutil.colors.gray("No Change ..... "), keyname); | ||
callback(null); | ||
// AWS ETag doesn't match local ETag | ||
gutil.log(gutil.colors.gray("No Change ..... "), keyname); | ||
callback(null); | ||
} else { | ||
} else { | ||
objOpts = helper.filterOptions(options); | ||
objOpts = helper.filterOptions(options); | ||
objOpts.Bucket = the_bucket; | ||
objOpts.Key = keyname; | ||
objOpts.Body = file.contents; | ||
if(mimetype.length) { | ||
// A check in case of map ContentType | ||
objOpts.ContentType = mimetype; | ||
} | ||
objOpts.Bucket = the_bucket; | ||
objOpts.Key = keyname; | ||
objOpts.Body = file.contents; | ||
if(mimetype.length) { | ||
// A check in case of map ContentType | ||
objOpts.ContentType = mimetype; | ||
} | ||
if(!_.isNull(metadata)) { | ||
// existing objOpts.Metadata gets overwrriten | ||
objOpts.Metadata = metadata; | ||
} | ||
if(!_.isNull(metadata)) { | ||
// existing objOpts.Metadata gets overwrriten | ||
objOpts.Metadata = metadata; | ||
} | ||
if(!_.isNull(metadata)) { | ||
// existing objOpts.ContentEncoding gets overwrriten | ||
objOpts.ContentEncoding = content_encoding; | ||
} | ||
if(!_.isNull(metadata)) { | ||
// existing objOpts.ContentEncoding gets overwrriten | ||
objOpts.ContentEncoding = content_encoding; | ||
} | ||
if (options.uploadNewFilesOnly && !head_data || !options.uploadNewFilesOnly) { | ||
if (options.uploadNewFilesOnly && !head_data || !options.uploadNewFilesOnly) { | ||
gutil.log(gutil.colors.cyan("Uploading ..... "), keyname); | ||
gutil.log(gutil.colors.cyan("Uploading ..... "), keyname); | ||
_s3.putObject(objOpts, function (err, data) { | ||
_s3.putObject(objOpts, function (err, data) { | ||
if (err) { | ||
return callback(new gutil.PluginError(PLUGIN_NAME, "S3 putObject Error: " + err.stack)); | ||
} | ||
console.log(err, data); | ||
if (err) { | ||
return callback(new gutil.PluginError(PLUGIN_NAME, "S3 putObject Error: " + err.stack)); | ||
} | ||
if (head_data) { | ||
if (head_data.ETag !== data.ETag) { | ||
gutil.log(gutil.colors.yellow("Updated ....... "), keyname); | ||
} else { | ||
gutil.log(gutil.colors.gray("No Change ..... "), keyname); | ||
} | ||
if (head_data) { | ||
if (head_data.ETag !== data.ETag) { | ||
gutil.log(gutil.colors.yellow("Updated ....... "), keyname); | ||
} else { | ||
// Doesn't exist in bucket; the object is new to the bucket | ||
gutil.log(gutil.colors.green("Uploaded! ..... "), keyname); | ||
gutil.log(gutil.colors.gray("No Change ..... "), keyname); | ||
} | ||
} else { | ||
// Doesn't exist in bucket; the object is new to the bucket | ||
gutil.log(gutil.colors.green("Uploaded! ..... "), keyname); | ||
} | ||
callback(null); | ||
}); | ||
} | ||
callback(null); | ||
}); | ||
} | ||
}); | ||
} | ||
}); | ||
@@ -231,0 +223,0 @@ }); |
{ | ||
"name": "gulp-s3-upload", | ||
"version": "1.4.1", | ||
"version": "1.4.2", | ||
"description": "A gulp task to asynchronous upload/update assets to an AWS S3 Bucket.", | ||
@@ -29,3 +29,3 @@ "main": "index.js", | ||
"dependencies": { | ||
"aws-sdk": "2.2.4", | ||
"aws-sdk": "2.2.6", | ||
"event-stream": "^3.3.1", | ||
@@ -32,0 +32,0 @@ "gulp-util": "^3.0.6", |
# gulp-s3-upload | ||
__Version 1.4.1__ | ||
__Version 1.4.2__ | ||
@@ -4,0 +4,0 @@ Use for uploading assets to Amazon S3 servers. |
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
28568
232
+ Addedaws-sdk@2.2.6(transitive)
- Removedaws-sdk@2.2.4(transitive)
Updatedaws-sdk@2.2.6