From 60d3155cbdf947d6efb8bcc6bd4ab1a6259b1786 Mon Sep 17 00:00:00 2001 From: Alexandr Murashkin Date: Fri, 19 May 2017 12:11:30 -0400 Subject: [PATCH] Handle promises correctly --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index db796d6..4628162 100644 --- a/index.js +++ b/index.js @@ -14,17 +14,17 @@ module.exports = class TracingConfigPlugin { const service = this.serverless.service; const stage = this.options.stage; const providerLevelTracingEnabled = (service.provider.tracing === true); - Object.keys(service.functions).forEach(functionName => { - this.toggleTracing(`${service.service}-${stage}-${functionName}`, + return Promise.all(Object.keys(service.functions).map(functionName => { + return this.toggleTracing(`${service.service}-${stage}-${functionName}`, (service.functions[functionName].tracing === true) || (providerLevelTracingEnabled && service.functions[functionName].tracing !== false) ); - }); + })); } toggleTracing(functionName, isEnabled) { this.serverless.cli.log(`Tracing ${isEnabled ? 'ENABLED' : 'DISABLED'} for function "${functionName}"`); - this.aws.request('Lambda', 'updateFunctionConfiguration', { + return this.aws.request('Lambda', 'updateFunctionConfiguration', { FunctionName: functionName, TracingConfig: { Mode: isEnabled === true ? 'Active' : 'PassThrough'