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
This commit is contained in:
Mariusz Nowak 2021-03-25 11:33:48 +01:00 committed by Mariusz Nowak
parent f1af86ab55
commit 64684f2ed5

View File

@ -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) {