Skip to content

Commit

Permalink
only filter options when passing to knox
Browse files Browse the repository at this point in the history
  • Loading branch information
coen-hyde committed Aug 15, 2013
1 parent be70b89 commit 33630fb
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions tasks/lib/s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,15 @@ exports.init = function (grunt) {
var makeOptions = exports.makeOptions = function(opts) {
var options = _.clone(opts || {}, true);

options = _.pick(options, [
'region', 'endpoint', 'port', 'key', 'secret', 'access', 'bucket', 'secure', 'headers', 'debug', 'style'
]);

return options;
};

var makeClient = function(options) {
return knox.createClient(_.pick(options, [
'region', 'endpoint', 'port', 'key', 'secret', 'access', 'bucket', 'secure', 'headers', 'style'
]));
};

/**
* Publishes the local file at src to the s3 dest.
*
Expand Down Expand Up @@ -108,7 +110,7 @@ exports.init = function (grunt) {
}

// Pick out the configuration options we need for the client.
var client = knox.createClient(options);
var client = makeClient(options);

if (options.debug) {
return dfd.resolve(util.format(MSG_UPLOAD_DEBUG, path.relative(process.cwd(), src), client.bucket, dest)).promise();
Expand Down Expand Up @@ -227,7 +229,7 @@ exports.init = function (grunt) {
var options = makeOptions(opts);

// Pick out the configuration options we need for the client.
var client = knox.createClient(options);
var client = makeClient(options);

if (options.debug) {
return dfd.resolve(util.format(MSG_DOWNLOAD_DEBUG, client.bucket, src, path.relative(process.cwd(), dest))).promise();
Expand Down Expand Up @@ -297,7 +299,7 @@ exports.init = function (grunt) {
var options = makeOptions(opts);

// Pick out the configuration options we need for the client.
var client = knox.createClient(options);
var client = makeClient(options);

if (options.debug) {
return dfd.resolve(util.format(MSG_COPY_DEBUG, src, client.bucket, dest)).promise();
Expand Down Expand Up @@ -341,7 +343,7 @@ exports.init = function (grunt) {
var options = makeOptions(opts);

// Pick out the configuration options we need for the client.
var client = knox.createClient(options);
var client = makeClient(options);

if (options.debug) {
return dfd.resolve(util.format(MSG_DELETE_DEBUG, client.bucket, src)).promise();
Expand Down Expand Up @@ -379,7 +381,7 @@ exports.init = function (grunt) {
var options = makeOptions(opts);

// Pick out the configuration options we need for the client.
var client = knox.createClient(options);
var client = makeClient(options);

if (options.debug) {
return dfd.resolve(util.format(MSG_SKIP_DEBUG, client.bucket, src)).promise();
Expand Down

0 comments on commit 33630fb

Please sign in to comment.