Browse Source

support environment variables on 'run'

master
Pete Miller 8 years ago
committed by GitHub
parent
commit
754482e7a7
  1. 10
      lib/run.js

10
lib/run.js

@ -44,6 +44,13 @@ module.exports = {
};
},
setEnvironmentVars(functionName) {
const providerEnvVars = this.serverless.service.provider.environment || {};
const functionEnvVars = this.serverless.service.functions[functionName].environment || {};
Object.assign(process.env, providerEnvVars, functionEnvVars);
},
run(stats) {
const functionName = this.options.function;
@ -52,6 +59,7 @@ module.exports = {
const handler = this.loadHandler(stats, functionName);
const event = this.getEvent();
const context = this.getContext(functionName);
this.setEnvironmentVars(functionName);
return new BbPromise((resolve, reject) => handler(
event,
@ -80,6 +88,8 @@ module.exports = {
const handler = this.loadHandler(stats, functionName, true);
const event = this.getEvent();
const context = this.getContext(functionName);
this.setEnvironmentVars(functionName);
handler(
event,
context,

Loading…
Cancel
Save