From e85ef0358b666560b0a1fbb8c543c2454aaf72bf Mon Sep 17 00:00:00 2001 From: Cristopher Pinzon Date: Thu, 31 Oct 2024 18:12:32 -0500 Subject: [PATCH] patch mounting of code if the function uses a lamda --- example/service/serverless.yml | 2 +- spec/helpers/services.js | 2 +- src/index.js | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/example/service/serverless.yml b/example/service/serverless.yml index ea87fe8..028c48c 100644 --- a/example/service/serverless.yml +++ b/example/service/serverless.yml @@ -4,7 +4,7 @@ provider: name: aws profile: ${opt:profile, self:custom.profile} stage: ${opt:stage, self:custom.defaultStage} - runtime: nodejs16.x + runtime: nodejs20.x lambdaHashingVersion: '20201221' custom: diff --git a/spec/helpers/services.js b/spec/helpers/services.js index 8d8b690..2ab0a40 100644 --- a/spec/helpers/services.js +++ b/spec/helpers/services.js @@ -16,7 +16,7 @@ const defaultConfig = { service: 'aws-nodejs', provider: { name: 'aws', - runtime: 'nodejs12.x', + runtime: 'nodejs20.x', lambdaHashingVersion: '20201221', environment: { LAMBDA_STAGE: diff --git a/src/index.js b/src/index.js index 0b62f25..a56318d 100644 --- a/src/index.js +++ b/src/index.js @@ -198,10 +198,10 @@ class LocalstackPlugin { // Patch plugin methods function compileFunction(functionName) { - if (!this.shouldMountCode()) { + const functionObject = this.serverless.service.getFunction(functionName); + if (functionObject.image || !this.shouldMountCode()) { return compileFunction._functionOriginal.apply(null, arguments); } - const functionObject = this.serverless.service.getFunction(functionName); functionObject.package = functionObject.package || {}; functionObject.package.artifact = __filename; return compileFunction._functionOriginal