From 64684f2ed58e643726e4cea403b80af9844575ab Mon Sep 17 00:00:00 2001 From: Mariusz Nowak Date: Thu, 25 Mar 2021 11:33:48 +0100 Subject: [PATCH] fix(CLI): Ensure to copy and not modify preset schemas While modyfing should not be problematic for regular usage, it introduces unexpected states to tests which test multiple runs in same process run --- lib/cli/commands-schema/resolve-final.js | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/lib/cli/commands-schema/resolve-final.js b/lib/cli/commands-schema/resolve-final.js index f7ea05af0..791c0e1f5 100644 --- a/lib/cli/commands-schema/resolve-final.js +++ b/lib/cli/commands-schema/resolve-final.js @@ -50,11 +50,7 @@ module.exports = (loadedPlugins, { providerName }) => { for (const hookName of Object.keys(loadedPlugin.hooks)) { const awsCommandName = optionalServiceCommandsHooksMap.get(hookName); if (awsCommandName && !commands.has(awsCommandName)) { - const awsCommandSchema = awsServiceCommands.get(awsCommandName); - const schema = { - ...awsCommandSchema, - options: { ...awsCommandSchema.options }, - }; + const schema = _.merge({}, awsServiceCommands.get(awsCommandName)); for (const awsSpecificOptionName of awsSpecificOptionNames) { delete schema.options[awsSpecificOptionName]; } @@ -70,13 +66,15 @@ module.exports = (loadedPlugins, { providerName }) => { if (commandConfig.type === 'entrypoint') continue; const fullCommandName = `${commandPrefix}${commandName}`; if (commandConfig.type !== 'container') { - const schema = commands.get(fullCommandName) || { - usage: commandConfig.usage, - serviceDependencyMode: 'required', - isHidden: commandConfig.isHidden, - noSupportNotice: commandConfig.noSupportNotice, - options: {}, - }; + const schema = commands.has(fullCommandName) + ? _.merge({}, commands.get(fullCommandName)) + : { + usage: commandConfig.usage, + serviceDependencyMode: 'required', + isHidden: commandConfig.isHidden, + noSupportNotice: commandConfig.noSupportNotice, + options: {}, + }; if (commandConfig.lifecycleEvents) schema.lifecycleEvents = commandConfig.lifecycleEvents; if (commandConfig.options) {