mirror of
https://github.com/jmwtsn/qmk_firmware.git
synced 2026-06-03 19:53:31 -03:00
Fail when a duplicate module name is detected (#26238)
This commit is contained in:
+14
-1
@@ -1137,4 +1137,17 @@ def get_modules(keyboard, keymap_filename):
|
|||||||
if keymap_json:
|
if keymap_json:
|
||||||
modules.extend(keymap_json.get('modules', []))
|
modules.extend(keymap_json.get('modules', []))
|
||||||
|
|
||||||
return list(dict.fromkeys(modules)) # remove dupes
|
# remove duplicates while maintaining the current order
|
||||||
|
ret = list(dict.fromkeys(modules))
|
||||||
|
|
||||||
|
# We currently do not support duplicate module names
|
||||||
|
# e.g.: ['foo/hello_world', 'bar/hello_world'] will fail
|
||||||
|
seen = set()
|
||||||
|
for module in ret:
|
||||||
|
module_slug = Path(module).name.lower()
|
||||||
|
if module_slug in seen:
|
||||||
|
duplicates = list(filter(lambda m: module_slug == Path(m).name.lower(), ret))
|
||||||
|
raise Exception(f'Duplicate module name detected: "{module_slug}" - {duplicates}')
|
||||||
|
seen.add(module_slug)
|
||||||
|
|
||||||
|
return ret
|
||||||
|
|||||||
Reference in New Issue
Block a user