check mmdc via running in case of setup failed.

This commit is contained in:
geekan 2023-07-04 11:09:26 +08:00
parent 22fd9fd49a
commit 748ef5535a
2 changed files with 3 additions and 2 deletions

View file

@ -13,7 +13,7 @@ from metagpt.logs import logger
from metagpt.utils.common import check_cmd_exists
def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, height=2048):
def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, height=2048) -> int:
"""suffix: png/svg/pdf
:param mermaid_code: mermaid code
@ -29,6 +29,7 @@ def mermaid_to_file(mermaid_code, output_file_without_suffix, width=2048, height
tmp.write_text(mermaid_code, encoding='utf-8')
if check_cmd_exists('mmdc') != 0:
logger.warning("RUN `npm install -g @mermaid-js/mermaid-cli` to install mmdc")
return -1
for suffix in ['pdf', 'svg', 'png']: