Skip to content

Commit

Permalink
Fixes #31 by ignoring the first key (glob).
Browse files Browse the repository at this point in the history
Invalid s3 config will still cause rejection and failure to set metadata
by s3 call
  • Loading branch information
Larry M. Sanders committed Sep 27, 2019
1 parent 30b801c commit fee840c
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
11 changes: 10 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ServerlessS3Sync {
s.params.forEach((param) => {
const glob = Object.keys(param)[0];
if(minimatch(localFile, `${path.resolve(localDir)}/${glob}`)) {
Object.assign(s3Params, param[glob] || {});
Object.assign(s3Params, this.extractMetaParams(param) || {});
}
});
}
Expand Down Expand Up @@ -178,6 +178,15 @@ class ServerlessS3Sync {
cli.consoleLog(`${messagePrefix}${chalk.yellow('Removed.')}`);
});
}

extractMetaParams(config) {
const validParams = {};
const keys = Object.keys(config);
for (let i = 1; i < keys.length; i++) {
validParams[keys[i]] = config[keys[i]];
}
return validParams;
}
}

module.exports = ServerlessS3Sync;
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-s3-sync",
"version": "1.9.0",
"version": "1.9.1",
"description": "A plugin to sync local directories and S3 prefixes for Serverless Framework.",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit fee840c

Please sign in to comment.