From 18362427cbd1450e7843804c0abd151c8b82f7a6 Mon Sep 17 00:00:00 2001 From: Russell Pekala Date: Fri, 29 Jan 2021 12:43:43 -0600 Subject: [PATCH] start non-SQS lambdas, default to localhost --- packages/serverless-offline-sqs/src/index.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/packages/serverless-offline-sqs/src/index.js b/packages/serverless-offline-sqs/src/index.js index 1e1ff7d4..19be74d3 100644 --- a/packages/serverless-offline-sqs/src/index.js +++ b/packages/serverless-offline-sqs/src/index.js @@ -61,10 +61,12 @@ class ServerlessOfflineSQS { const {sqsEvents, lambdas} = this._getEvents(); - this._createLambda(lambdas); - const eventModules = []; + if(lambdas.length > 0){ + eventModules.push(this._createLambda(lambdas)); + } + if (sqsEvents.length > 0) { eventModules.push(this._createSqs(sqsEvents)); } @@ -119,10 +121,17 @@ class ServerlessOfflineSQS { } } - _createLambda(lambdas) { + async _createLambda(events, skipStart) { + if(!this.options.host){ + this.options.host = 'localhost'; + } this.lambda = new Lambda(this.serverless, this.options); - this.lambda.create(lambdas); + await this.lambda.create(events); + + if (!skipStart) { + await this.lambda.start(); + } } async _createSqs(events, skipStart) {