Skip to content

Commit

Permalink
Make shouldTargetCommand recursive
Browse files Browse the repository at this point in the history
  • Loading branch information
kemmerle committed Dec 20, 2024
1 parent 659c383 commit 312431e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,21 +149,24 @@ const setRequestHeaders = () => {
};

const shouldTargetCommand = (options, commandMap) => {
return options._.every(command => {
const checkCommand = (command, map) => {
const mainCommand = command;
if (commandMap[mainCommand]) {
if (commandMap[mainCommand].target) {

if (map[mainCommand]) {
if (map[mainCommand].target && options._.includes(mainCommand)) {
return false;
}
const subCommands = commandMap[mainCommand].subCommands || {};
const subCommands = map[mainCommand].subCommands || {};
for (const subCommand in subCommands) {
if (subCommands[subCommand]?.target && options._.includes(subCommand)) {
if (!checkCommand(subCommand, subCommands)) {
return false;
}
}
}
return true;
});
};

return options._.every(command => checkCommand(command, commandMap));
};

const SKIP_CONFIG_VALIDATION = {
Expand Down

0 comments on commit 312431e

Please sign in to comment.