From 8c3b00a146ece27cc2529d974b2e0d94482e0b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Van=20Dal?= Date: Tue, 13 Aug 2019 11:15:00 -0300 Subject: [PATCH 1/3] fix: sets env vars in provider.environment --- src/index.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 1f15ac5..4a7b8b2 100644 --- a/src/index.js +++ b/src/index.js @@ -84,7 +84,7 @@ class ServerlessEnvGeneratorPlugin { .on('exit', () => { if (fs.existsSync(config.dotEnvPath)) { fs.removeSync(config.dotEnvPath); - this.serverless.cli.log('Removed .env file') + this.serverless.cli.log('Removed .env file') } }) return helper.getEnvVars(undefined, true, config).then(envFiles => { @@ -106,7 +106,7 @@ class ServerlessEnvGeneratorPlugin { }) } - // Sets options.environment used by serverless-local-dev-server + // Sets environment vars in serverless.service.provider.environment setEnvironment() { const config = this.getConfig() this.serverless.cli.log('Setting YAML environment variables …') @@ -117,7 +117,7 @@ class ServerlessEnvGeneratorPlugin { environment[envVar.attribute] = envVar.value }) }) - this.options.environment = Object.assign(this.serverless.service.provider.environment, environment, dotenv.config({ path: path.join(config.servicePath, '.env.local') }).parsed) + this.serverless.service.provider.environment = Object.assign(this.serverless.service.provider.environment || {}, environment, dotenv.config({ path: path.join(config.servicePath, '.env.local') }).parsed) }) } From 7a81f9d3fa821260969668eb231015e01d833700 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Van=20Dal?= Date: Tue, 13 Aug 2019 11:15:43 -0300 Subject: [PATCH 2/3] fix: deprecated hook --- src/index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 4a7b8b2..99e8a27 100644 --- a/src/index.js +++ b/src/index.js @@ -47,8 +47,8 @@ class ServerlessEnvGeneratorPlugin { 'invoke:test:test': this.writeDotEnvFile.bind(this), 'before:deploy:function:packageFunction': this.writeDotEnvFile.bind(this), 'after:deploy:function:packageFunction': this.removeDotEnvFile.bind(this), - 'before:deploy:createDeploymentArtifacts': this.writeDotEnvFile.bind(this), - 'after:deploy:createDeploymentArtifacts': this.removeDotEnvFile.bind(this), + 'before:package:createDeploymentArtifacts': this.writeDotEnvFile.bind(this), + 'after:package:createDeploymentArtifacts': this.removeDotEnvFile.bind(this), 'before:offline:start:init': this.setEnvironment.bind(this), 'before:invoke:local:invoke': this.writeDotEnvFile.bind(this), 'after:invoke:local:invoke': this.removeDotEnvFile.bind(this), From eaf3c98e1b8fdca644ae6f131c0ce9bd45693803 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Van=20Dal?= Date: Tue, 13 Aug 2019 11:15:59 -0300 Subject: [PATCH 3/3] chore: remove local-dev-server:loadEnvVars --- src/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index 99e8a27..b0e6ed2 100644 --- a/src/index.js +++ b/src/index.js @@ -51,8 +51,7 @@ class ServerlessEnvGeneratorPlugin { 'after:package:createDeploymentArtifacts': this.removeDotEnvFile.bind(this), 'before:offline:start:init': this.setEnvironment.bind(this), 'before:invoke:local:invoke': this.writeDotEnvFile.bind(this), - 'after:invoke:local:invoke': this.removeDotEnvFile.bind(this), - 'local-dev-server:loadEnvVars': this.setEnvironment.bind(this) + 'after:invoke:local:invoke': this.removeDotEnvFile.bind(this) } }