Skip to content

Commit f8fc978

Browse files
authored
Merge pull request #172 from olehermanse/validation
Fixed issues with remove and clean commands when build key is missing
2 parents 0dd99d6 + 84bedd7 commit f8fc978

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

cfbs/commands.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,10 @@ def add_command(
392392
def remove_command(to_remove: list):
393393
config = CFBSConfig.get_instance()
394394
config.warn_about_unknown_keys()
395+
if not "build" in config:
396+
user_error(
397+
'Cannot remove any modules because the "build" key is missing from cfbs.json'
398+
)
395399
modules = config["build"]
396400

397401
def _get_module_by_name(name) -> dict:
@@ -478,7 +482,12 @@ def _clean_unused_modules(config=None):
478482
if not config:
479483
config = CFBSConfig.get_instance()
480484
config.warn_about_unknown_keys()
485+
if "build" not in config:
486+
log.warning('No "build" key with modules - nothing to clean')
487+
return 0
481488
modules = config["build"]
489+
if len(modules) == 0:
490+
return 0
482491

483492
def _someone_needs_me(this) -> bool:
484493
if "added_by" not in this or this["added_by"] == "cfbs add":

0 commit comments

Comments
 (0)