mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
Filter nested entrypoints on getCommands(). Used by help.
This commit is contained in:
parent
7e65a22a8b
commit
b73466641e
@ -173,9 +173,26 @@ class PluginManager {
|
||||
}
|
||||
|
||||
getCommands() {
|
||||
// Return filtered list of visible commands
|
||||
const cmds = _.omitBy(this.commands, ['type', 'entrypoint']);
|
||||
return cmds;
|
||||
const result = {};
|
||||
|
||||
// Iterate through the commands and stop at entrypoints to include only public
|
||||
// command throughout the hierarchy.
|
||||
const stack = [{ commands: this.commands, target: result }];
|
||||
while (!_.isEmpty(stack)) {
|
||||
const currentCommands = stack.pop();
|
||||
const commands = currentCommands.commands;
|
||||
const target = currentCommands.target;
|
||||
_.forOwn(commands, (command, name) => {
|
||||
if (command.type !== 'entrypoint') {
|
||||
_.set(target, name, _.omit(command, 'commands'));
|
||||
if (_.some(command.commands, childCommand => childCommand.type !== 'entrypoint')) {
|
||||
target[name].commands = {};
|
||||
stack.push({ commands: command.commands, target: target[name].commands });
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user