From cd310ddea838b935970540e24c9cc7b924d32983 Mon Sep 17 00:00:00 2001 From: ljacobsson Date: Wed, 23 Aug 2023 07:57:30 +0200 Subject: [PATCH] fix: ignore inline funcs during cleanup --- package.json | 2 +- src/commands/local/lib/cleanup.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 789085d..16e1dc7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "samp-cli", - "version": "1.0.47", + "version": "1.0.48", "description": "CLI tool for extended productivity with AWS Serverless Application Model (SAM)", "main": "index.js", "scripts": { diff --git a/src/commands/local/lib/cleanup.js b/src/commands/local/lib/cleanup.js index 99f5167..490eefe 100644 --- a/src/commands/local/lib/cleanup.js +++ b/src/commands/local/lib/cleanup.js @@ -55,7 +55,10 @@ const updatePromises = functions.map(async functionName => { try { const func = template.Resources[functionName]; const physicalId = stackResources.find(resource => resource.LogicalResourceId === functionName).PhysicalResourceId; - + validateNotIntrinsicFunction(func.Properties.Timeout, "Timeout", "number"); + validateNotIntrinsicFunction(func.Properties.MemorySize, "MemorySize", "number"); + validateNotIntrinsicFunction(func.Properties.Handler, "Handler", "string"); + validateNotIntrinsicFunction(func.Properties.Runtime, "Runtime", "string"); await lambdaClient.send(new UpdateFunctionConfigurationCommand({ FunctionName: physicalId, Timeout: func.Properties.Timeout, @@ -104,6 +107,13 @@ const updatePromises = functions.map(async functionName => { }); +function validateNotIntrinsicFunction(obj, name, expectedDataType) { + if (typeof obj === "object") { + console.log(`Tried to restore ${name}, but it's set using an intrinsic function which isn't supported. Please use a ${expectedDataType} instead`); + process.exit(1); + } +} + // Wait for all promises to resolve await Promise.all(updatePromises); console.log("Finished restoring functions");