Skip to content

Commit

Permalink
Merge pull request #172 from olehermanse/validation
Browse files Browse the repository at this point in the history
Fixed issues with remove and clean commands when build key is missing
  • Loading branch information
olehermanse authored Jan 8, 2024
2 parents 0dd99d6 + 84bedd7 commit f8fc978
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions cfbs/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ def add_command(
def remove_command(to_remove: list):
config = CFBSConfig.get_instance()
config.warn_about_unknown_keys()
if not "build" in config:
user_error(
'Cannot remove any modules because the "build" key is missing from cfbs.json'
)
modules = config["build"]

def _get_module_by_name(name) -> dict:
Expand Down Expand Up @@ -478,7 +482,12 @@ def _clean_unused_modules(config=None):
if not config:
config = CFBSConfig.get_instance()
config.warn_about_unknown_keys()
if "build" not in config:
log.warning('No "build" key with modules - nothing to clean')
return 0
modules = config["build"]
if len(modules) == 0:
return 0

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

0 comments on commit f8fc978

Please sign in to comment.