From fd97e877cec6397cccf0e2bb2d1bfb5d71bdd798 Mon Sep 17 00:00:00 2001 From: Piotr Grzesik Date: Wed, 28 Apr 2021 15:27:17 +0200 Subject: [PATCH] refactor: Ensure that `options` are copied in Serverless constructor --- lib/Serverless.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/Serverless.js b/lib/Serverless.js index 679c98069..ef0f66058 100644 --- a/lib/Serverless.js +++ b/lib/Serverless.js @@ -87,7 +87,10 @@ class Serverless { this._shouldReportMissingServiceDeprecation = true; } const commands = ensureArray(configObject.commands, { isOptional: true }); - const options = ensurePlainObject(configObject.options, { isOptional: true }); + let options = ensurePlainObject(configObject.options, { isOptional: true }); + // This is a temporary workaround to ensure that original `options` are not mutated + // Should be removed after addressing: https://github.com/serverless/serverless/issues/2582 + if (options) options = { ...options }; if (!commands || !options) { this._shouldReportCommandsDeprecation = true; this.processedInput = resolveCliInput();