From fee840ce501fed86ce285b8959bbf7d7170bbec2 Mon Sep 17 00:00:00 2001 From: "Larry M. Sanders" Date: Fri, 27 Sep 2019 06:01:25 -0500 Subject: [PATCH] Fixes k1LoW/serverless-s3-sync#31 by ignoring the first key (glob). Invalid s3 config will still cause rejection and failure to set metadata by s3 call --- index.js | 11 ++++++++++- package-lock.json | 2 +- package.json | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/index.js b/index.js index ae31314..bde4eed 100644 --- a/index.js +++ b/index.js @@ -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) || {}); } }); } @@ -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; diff --git a/package-lock.json b/package-lock.json index bdbb3c6..c8eafb3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "serverless-s3-sync", - "version": "1.8.0", + "version": "1.9.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index 5e8ebc9..84bbfbc 100644 --- a/package.json +++ b/package.json @@ -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": {