Add CLI module deduplication and improve conflict reporting
Individual CLI modules now silently take precedence over array-sourced modules (e.g. from cli-defaults) when their commands overlap. Conflict errors between non-array modules include both package names for easier debugging. Commands reference their parent module instead of storing a raw package name string. createCliModule now validates that packageJson has a name. Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com> Made-with: Cursor
This commit is contained in:
@@ -55,6 +55,12 @@ export function createCliModule(options: {
|
||||
addCommand: (command: CliCommand) => void;
|
||||
}) => Promise<void>;
|
||||
}): CliModule {
|
||||
if (!options.packageJson.name) {
|
||||
throw new Error(
|
||||
'The packageJson provided to createCliModule must have a name',
|
||||
);
|
||||
}
|
||||
|
||||
const commands: CliCommand[] = [];
|
||||
const commandsPromise = options
|
||||
.init({ addCommand: command => commands.push(command) })
|
||||
|
||||
Reference in New Issue
Block a user