Skip to content

Commit

Permalink
Optimized command validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Sukairo-02 committed Jul 10, 2024
1 parent 61507dd commit 8031823
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/command-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,9 +325,7 @@ export const command = <
>(command: RawCommand<TOpts, TOptsData, TTransformed>): Command<TOptsData, Awaited<TTransformed>> => {
const allNames = command.aliases ? [command.name, ...command.aliases] : [command.name];

const processedOptions = command.options ? validateOptions(command.options) : undefined;
const cmd: Command = clone(command) as any;

if (
(<AnyRawCommand> command).subcommands && command.options
&& Object.values(command.options).find((opt) => opt._.config.type === 'positional')
Expand All @@ -336,6 +334,8 @@ export const command = <
`Can't define command '${cmd.name}' - command can't have subcommands and positional args at the same time!`,
);
}

const processedOptions = command.options ? validateOptions(command.options) : undefined;
cmd.options = processedOptions;

cmd.name = cmd.name ?? cmd.aliases?.shift();
Expand Down

0 comments on commit 8031823

Please sign in to comment.